SortPairsAscending, SortPairsDescending

Description

Sort a list of two-item lists.

Type

LIST

Arguments

Type

Meaning

1

LIST {LIST}

the list of lists to be sorted.

Evaluation

The input list must be a list of lists, each member list must contain at least two items. The pairs are sorted into ascending/descending order by the second item’s value, and a list containing the first items of this sorted list of pairs is returned. Duplicates are not removed.

Comments

Comparisons across type are defined by the following arbitrary ordering, on which users are advised against relying:

BOOLEAN < NUMERIC < STRING < OBJECT < SLOT <

DATETIME < LIST

Within each type, ordering is as:

  • BOOLEAN: TRUE < FALSE
  • NUMERIC: values involving different dimensions are sorted by lexicographic ordering on the names of the units; within values of the same dimensionality, the sorting is based on standard numeric comparisons.
  • STRING: Lexicographic ordering
  • OBJECT: Lexicographic ordering on the object’s name
  • SLOT: Lexicographic ordering on the slot’s name
  • DATETIME: Same as RPL operator
  • LIST: Based on comparison of items within the list (left to right).
 
SortPairsAscending({{"a", 10.0} , {"b", 2.0}, {"c", 5.0}, {"d", 10.0}})
 
{"b", "c", "a", "d"}