Budgie supports four forms of sorting lists, all in-place.
As Numbers
For lists of type int or double, or a generic guaranteed to only ever either of those numeric types, you can sort the list with list sort numbers. It takes in the name of the list and sorts it with numeric comparisons.
JavaScript runtimes default to sorting values as strings, so this will pass in a lambda to compare them as numbers as needed.
variable : numbers { list type : int } { list new : int 20 5 15 10 }
comment line : 5, 10, 15, 20
list sort numbers : numbers
Lists of complex objects, namely class or interface instances, can be sorted by a single keyed member of those objects. list sort member numbers takes in the name of a list, the privacy type of members, a name for instances inside a comparison lambda, and the PascalCase key to look up under the instances.
Members will be compared using the built-in < operator.
class start : Size
member variable declare : public Count int
constructor start : public Size count int
operation : { member variable : public { this } Count } equals count
constructor end
class end
comment line : ...
variable : sizes { list type : Size } { list new : Size { new : Size 3 } { new : Size 1 } { new : Size 2 } }
comment line : 1, 2, 3
list sort member numbers : sizes public size Count
list sort member strings takes in the name of a list, the privacy type of members, a name for instances inside a comparison lambda, and the PascalCase key to look up under the instances. It's equivalent to list sort member numbers but compares members using built-in string comparisons.
class start : Fruit
member variable declare : public Name string
constructor start : public Fruit name string
operation : { member variable : public { this } Name } equals name
constructor end
class end
comment line : ...
variable : fruits { list type : Fruit } { list new : Fruit { new : Person "banana" } { new : Person "cherry" } { new : Person "apple" } }
comment line : "apple", "banana", "cherry"
list sort member strings : fruits public fruit Name