Implement `Comparable`, `Sort` methods
MajorLift opened this issue · comments
Currently, we only have comparators for number types. We should implement coherent logic around handling comparable types in general.
-
List.Comparable
- Given a comparator function
F
and a listT
, return true iff every element ofT
is comparable usingF
. (F: Kind, T: Comparable[]) --> Boolean
- Given a comparator function
-
String.Compare
- Compares two strings by alphabetical order.
(A: String, B: String) --> -1 | 0 | 1
-
Object.Compare
- Compares two objects based on a given comparator.
(F: Kind, A: Record, B: Record) --> -1 | 0 | 1
-
List.Sort
- Given a list
T
of comparable types, sort the elements using the built-incompare
methods and return the result. (T: Comparable[]) --> ?[]
- Given a list
-
List.SortOn
- Given a comparator function
F
and a listT
of comparable types, sort the elements using the user-supplied comparator and return the result. (F: Kind, T: ?[]) --> ?[]
- Given a comparator function
-
List.Max
- Given a comparator function
F
and a listT
of comparable types, return the maximum. - (F: Kind, T: Comparable[]) --> Comparable
- Given a comparator function
-
List.Min
- Given a comparator function
F
and a listT
of comparable types, return the minimum. - (F: Kind, T: Comparable[]) --> Comparable
- Given a comparator function
The implementation should include unit tests and JSDoc comments that adhere to the guidelines established in the style-guide/
directory.