Difference between revisions of "Sort"
Jump to navigation
Jump to search
(Created page with "<c>sort</c> Sorts a list in place. With null or no argument, this sorts the list elements by their own values. See also: shuffle === Arguments === {| class="wikitabl...") |
|||
Line 1: | Line 1: | ||
− | <c>sort</c> | + | <c>sort</c> sorts a list in place. With null or no argument, this sorts the list elements by their own values. |
See also: [[shuffle]] | See also: [[shuffle]] |
Revision as of 15:41, 18 March 2020
sort
sorts a list in place. With null or no argument, this sorts the list elements by their own values.
See also: shuffle
Arguments
Parameter Name | Default Value | Meaning |
---|---|---|
self | list | list to sort |
byKey | optional | if given, sort each element by indexing with this key. |
Usage Notes
With the byKey argument, each element is indexed by that argument, and the elements are sorted by the result. (This only works if the list elements are maps, or they are lists and byKey is an integer index.)
Example
a = [5,3,4,1,2]; a.sort // results in a == [1, 2, 3, 4, 5]