 
      
      sortingArray sorting module. This module uses Quicksort and Counting Sort algorithms as its backend.
There are no constants.
compare() — Compare two valueslinear_rsort() — Sort an array of positive integers in linear time. Array elements will be arranged from highest to lowest. This function uses Counting Sort as its backendlinear_sort() — Sort an array of positive integers in linear time. Array elements will be arranged from lowest to highest. This function uses Counting Sort as its backendrsort() — Sort an array in reverse order. Array elements will be arranged from highest to lowestsort() — Sort an array. Array elements will be arranged from lowest to highestusort() — Sort an array using a user-defined comparison functionThere are no classes.
import sorting
 
start
    data = [
        {age: 20, name: "clara"},
        {age: 22, name: "vania"},
        {age: 18, name: "sarah"},
        {age: 17, name: "aisha"},
        {age: 18, name: "nifa"},
        {age: 19, name: "lisa"},
    ]
 
    usort(data, comparison())
    writer(data)
stop
 
function comparison(a, b)
    ' Compare a.age & b.age first, and then compare a.name & b.name
    ' if both ages are equal
 
    c = compare(a.age, b.age)
 
    if c == 0
        return compare(a.name, b.name)
    else
        return c
    endif
stop