Documentation ¶
Overview ¶
Package order provides helper functions and contraints to allow ordering streams
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IgnoreCase ¶
IgnoreCase implements order.Comparator for strings, ignoring the case.
func Int ¶
func Int[T constraints.Integer](a, b T) int
Int implements the Comparator for signed integers. This will be usually faster than Natural comparator
func Natural ¶
func Natural[T constraints.Ordered](a, b T) int
Natural implements the Comparator for those elements whose type has a natural order (numbers and strings)
func SortSlice ¶
func SortSlice[T any](slice []T, comparator Comparator[T])
SortSlice sorts the given slice according to the criteria in the provided comparator
Types ¶
type Comparator ¶
Comparator function compares its two arguments for order. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.
func ByKey ¶
func ByKey[K comparable, V any](cmp Comparator[K]) Comparator[item.Pair[K, V]]
ByKey uses the source comparator to compare the key of two item.Pair entries
func ByVal ¶
func ByVal[K, V comparable](cmp Comparator[V]) Comparator[item.Pair[K, V]]
ByVal uses the source comparator to compare the value of two item.Pair entries
func Inverse ¶
func Inverse[T any](cmp Comparator[T]) Comparator[T]
Inverse result of the Comparator function for inverted sorts