fromCompare<T> function
- int compare(
- T first,
- T second
Creates a new Ord instance given a compare function.
Example:
void main() {
// Create a compare function for integers
int compareInt(int x, int y) => x.compareTo(y);
// Create an Ord instance for integers using the compare function
Ord<int> ordInt = fromCompare(compareInt);
// Compare two integers using the ordInt instance
int result = ordInt.compare(5, 10); // Output: -1 (5 is less than 10)
}
Implementation
Ord<T> fromCompare<T>(int Function(T first, T second) compare) {
return _Ord(compare);
}