Skip to main content

Module sortops

Module sortops 

Source
Expand description

List-sorting builtins: msort/2, sort/2.

Ported byte-for-byte from patch-prolog v1 (solver.rs MSort/Sort arms). Both sort by the standard order of terms (compare_terms):

  • msort/2 is a stable sort that KEEPS duplicates.
  • sort/2 sorts and then removes adjacent Equal duplicates.

The first argument must be a proper list; otherwise v1 raises a type_error(list, Culprit) (oracle-verified). The result is built on the heap.

Functionsยง

plg_rt_b_msort_2
msort/2: stable sort by standard order, duplicates kept.
plg_rt_b_sort_2
sort/2: sort by standard order then drop adjacent Equal dups.