ceylon.language.sort.ceylon Maven / Gradle / Ivy
"Sort the given elements according to their
[[natural order|Comparable]], returning a new
[[sequence|Sequential]].
Note that [[Iterable.sort]] may be used to sort any stream
according to a given comparator function."
see (`interface Comparable`,
`function Iterable.sort`)
tagged("Streams", "Comparisons")
shared Element[] sort({Element*} elements)
given Element satisfies Comparable {
value array = Array(elements);
if (array.empty) {
return [];
}
else {
array.sortInPlace(byIncreasing(identity));
return ArraySequence(array);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy