predsort/3 removes duplicates, based on the predicate saying =
This bit me when I wanted to sort on a field in a dict.
Did you know ... | Search Documentation: |
Predicate predsort/3 |
<
, >
or
=
. Duplicates are removed (i.e. equivalence
classes of elements as defined by Pred are collapsed to a
single element in
Sorted) If the built-in predicate compare/3
is used, the result is the same as sort/2.
See also keysort/2.predsort/3 removes duplicates, based on the predicate saying =
This bit me when I wanted to sort on a field in a dict.
This absolutely needs to be extended to
predsort(+Pred, +List, -Sorted, +Flags)
Where Flags should at least accept "collapse_equivalence_classes(true)
", "collapse_equivalence_classes(false)
"
Here is another example of predsort in a rather disconcerting duplicate-killing action:
An example of hierarchical sorting using predsort/3 which takes care to not lose records via "duplicate elimination":
hierarchical_sorting_example.pl