sort
lib.sort
Primop
Docs pulled from | This Revision | about 1 hour ago
Takes 2 arguments
comparator, list
Sort a list based on a comparator function which compares two elements and returns true if the first argument is strictly below the second argument. The returned list is sorted in an increasing order. The implementation does a quick-sort.
See also sortOn
, which applies the
default comparison on a function-derived property, and may be more efficient.
Inputs
comparator
-
1. Function argument
list
-
2. Function argument
Type
sort :: (a -> a -> Bool) -> [a] -> [a]
Examples
lib.lists.sort
usage example
sort (p: q: p < q) [ 5 3 7 ]
=> [ 3 5 7 ]
Noogle detected
Implementation
This function is implemented in c++ and is part of the native nix runtime.