User Tools

Site Tools



This shows you the differences between two versions of the page.

Link to this comparison view

harlowe:sorted [2017/06/19 01:21]
l created
harlowe:sorted [2017/10/09 20:39]
Line 1: Line 1:
-**(sorted: // [[harlowe:​Number|Number]] or [[harlowe:​String|String]],​ ...Number or String//) -> //​[[harlowe:​Array|array]]//​** 
-Similar to [[harlowe:​a|(a:​)]],​ except that it requires only [[harlowe:​number|number]] or [[harlowe:​string|string]],​ and orders 
-them in English alphanumeric sort order, rather than the order in which they were provided. 
-=== Example usage: === 
-(set: $a to (a: '​A','​C','​E','​G',​ 2, 1)) 
-(print: (sorted: ...$a)) 
-=== Rationale: === 
-Often, you'll be using [[harlowe:​array|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 
-spread ''​%%...%%''​ syntax) convert an existing array into a sorted one. 
-=== Details: === 
-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. 
-=== See also: === 
-[[harlowe:​a|(a:​)]],​ [[harlowe:​shuffled|(shuffled:​)]],​ [[harlowe:​rotated|(rotated:​)]] 
harlowe/sorted.txt · Last modified: 2017/10/09 20:39 (external edit)