sort multimethod

Methods

sort(a:Arr, lte:Fun=method) Source: stdlib.ngs:2291
Sort an array.

Parameters

lteLess-then-or-equal function to use for comparison of the items in a

Returns

Arr

Example

sort([0,5,3,-1], (<=))  # [-1, 0, 3, 5]
sort(a:Arr, field:Str, lte:Fun=method) Source: stdlib.ngs:2304
Sort an array based on field value

Parameters

lteLess-then-or-equal function to use for comparison of the items' fields

Returns

Arr

Example

[{'x': 1}, {'x': 5}, {'x': 3}].sort('x')  # [{'x': 1}, {'x': 3}, {'x': 5}]
sort(h:Hash, lte:Fun=method) Source: stdlib.ngs:2767
Sort a Hash.

Parameters

lteLess-then-or-equal function to use for comparison of the keys in h

Returns

Hash

Example

{"b": 2, "c": 3, "a": 1}.sort()  # {"a": 1, "b": 2, "c": 3}