File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -189,4 +189,33 @@ stop at the point where the infinity is detected.
189
189
190
190
Returns a list with the elements in reverse order.
191
191
192
+ = head3 rotate
193
+
194
+ multi sub rotate(@list, Int:D $n = 1) returns List:D
195
+ multi method rotate(List:D: Int:D $n = 1) returns List:D
196
+
197
+ Returns the list rotated by C < $n > elements.
198
+
199
+ <a b c d e>.rotate(2); # <c d e a b>
200
+ <a b c d e>.rotate(-1); # <e a b c d>
201
+
202
+ = head3 sort
203
+
204
+ multi sub sort(*@elems) returns List:D
205
+ multi sub sort(&by, *@elems) returns List:D
206
+ multi method sort(List:D:) returns List:D
207
+ multi method sort(List:D:, &by) returns List:D
208
+
209
+ Sorts the list, smallest element first. By default C << infix:<cmp> >>
210
+ is used for comparing list elements.
211
+
212
+ If C < &by > is provided, and it accepts two arguments,
213
+ it is invoked for pairs of list elements, and should return
214
+ C < Order::Increase > , C < Order::Same > or C < Order::Decrease > .
215
+
216
+ If C < &by > accepts only one argument, the list elements are sorted
217
+ according to C << by($a) cmp by($b) >> . The return values of C < &by > are
218
+ cached, so that C < &by > is only called once per list element.
219
+
220
+
192
221
= end pod
You can’t perform that action at this time.
0 commit comments