(set: $a to (a: 'A','C','E','G', 2, 1)) (print: (sorted: ...$a))
Often, you'll be using array as 'decks' that will provide values to other parts of
your story in a specific order. If you want, for instance, several strings to appear in
alphabetical order, this macro can be used to create a sorted array, or (by using the
... syntax) convert an existing array into a sorted one.
Unlike other programming languages, strings aren't sorted using ASCII sort order, but alphanumeric sorting: the string “A2” will be sorted after “A1” and before “A11”. Moreover, if the player's web browser supports internationalisation (that is, every current browser except Safari 6-8 and IE 10), then the strings will be sorted using English language rules (for instance, “é” comes after “e” and before “f”, and regardless of the player's computer's language settings. Otherwise, it will sort using ASCII comparison (whereby “é” comes after “z”).
Currently there is no way to specify an alternative language locale to sort by, but this is likely to be made available in a future version of Harlowe.
To ensure that it's being used correctly, this macro requires two or more items - providing just one (or none) will cause an error to be presented.