function
Library: Sorting (OMSORT)
Import : omsort.xmd |
export function sort-by-key modifiable integer shelf-to-sortor
export function sort-by-key modifiable stream shelf-to-sortor
export function sort-by-key modifiable string shelf-to-sortor
export function sort-by-key modifiable switch shelf-to-sort
Argument definitions
Use sort.sort-by-key
to sort shelf-to-sort according to its keys in ascending
order. shelf-to-sort can have type integer
, stream
, string
, or switch
.
shelf-to-sort must have a key for every item, otherwise error 6052 will be thrown).
If shelf-to-sort is a stream
shelf, then it must
referents-allowed
, otherwise
error 6059 will be thrown, and
The following program sorts a list of integer
s by their keys:
import "omsort.xmd" prefixed by sort. process local integer integer-test-shelf variable initial { 1 with key "a", 2 with key "c", 3 with key "b"} sort.sort-by-key integer-test-shelf repeat over integer-test-shelf output "key " || key of integer-test-shelf || "; item " || "%d(integer-test-shelf)%n" again