Sort

Description

Sort the items in a list.

Type

LIST

Arguments

Type

Meaning

1

LIST

a list of values to be sorted

Evaluation

Returns a list with the same values as the input list, in increasing order.

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).
 
Sort({ 1.0, {res1, 10}, "hello", 0.0, "bob"})
 
{ 0.0, 1.0, "bob", "hello", {res1, 10}}