sort


sort(xs, @optional test, type) 
      

Return a list containing the elements of the list xs sorted according to test.

Test must be a function that take two arguments and return true if its first argument must precede its second in the sorted list. Duplicate elements are not removed or rearranged. The default value of test is number_is_lt which compares two numeric values.

Type specifies the sorting algorithm to use. In the current implementation, type can take two values: 'quick (for quicksort) and 'merge (for mergesort).

Examples:


sort([3, 4, 2, 1, 2, 5])
// [1, 2, 2, 3, 4, 5]

list_to_string(sort(string_to_list("hello"), char_is_lt, 'merge))
// ehllo
      

Also see:

zip
find
filter


Core Module Index | Contents