Module tql_compare

Data Types

comparator()

comparator(T) = fun((T, T) -> boolean())

order()

order() = ascending | descending

Function Index

by/1Equivalent to by(F, ascending).
by/2Creates a comparison function (comparator(A)) compatible with lists:sort/2, using the extracted term to sort in the given direction.
by_prop/1Equivalent to by_prop(Key, ascending).
by_prop/2Creates a comparator for maps, sorting by a given property, in the given direction.
by_prop/3Creates a comparator for maps, sorting by the given property and using the Default as fallback value, to sort in the provided direction.
concat/1Composes multiple comparators together.
reverse/1Reverses the order in which elements are sorted by a comparator.

Function Details

by/1

by(F::fun((A) -> B)) -> comparator(A)

Equivalent to by(F, ascending).

by/2

by(Extractor::fun((A) -> B), X2::order()) -> comparator(A)

Creates a comparison function (comparator(A)) compatible with lists:sort/2, using the extracted term to sort in the given direction.

by_prop/1

by_prop(Key::term()) -> comparator(map())

Equivalent to by_prop(Key, ascending).

by_prop/2

by_prop(Key::term(), Order::order()) -> comparator(map())

Creates a comparator for maps, sorting by a given property, in the given direction.

by_prop/3

by_prop(Key, Default, Order::order()) -> comparator(map())

Creates a comparator for maps, sorting by the given property and using the Default as fallback value, to sort in the provided direction.

concat/1

concat(Comparators::[Comp, ...]) -> Comp

Composes multiple comparators together.

Fallthrough happens when 2 items are considered equivalent _according to the comparators_. Specifically, this means when Compare(A, B) == Compare(B, A).

reverse/1

reverse(Comparator::comparator(T)) -> comparator(T)

Reverses the order in which elements are sorted by a comparator.


Generated by EDoc