All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ceylon.language.sort.ceylon Maven / Gradle / Ivy

There is a newer version: 1.3.3
Show newest version
"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