Link | alphasorter |
Author | Johan Solve |
Category | Array |
Version | 8.x |
License | Public Domain |
Posted | 10 Oct 2007 |
Updated | 10 Oct 2007 |
More by this author... |
Comparator to get arrays of strings (or arrays of pairs) sorted in the correct order for the Swedish language.
With normal array->sort the sort order will be ä, å, ö instead of the desired å, ä, ö.
This comparator is very limited. It will only look at the first character position of the strings, and does only care about the characters å, ä and ö.
Johan Sölve 2007-06-25
var: 'myarray'=(array: 'östen', 'åke', 'ärlig'); $myarray -> (sortwith: \alphasorter); $myarray; Result: array: (åke), (ärlig), (östen)
Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.
[//lasso define_tag: 'alphasorter', -required='left', -copy, -required='right', -copy; // used as comparator for proper sorting of arrays of strings (or array of string pairs) // otherwise the sorted order will be ä, å, ö // usage: $myarray -> (sortwith: \alphasorter); // Johan Sölve 2007-06-25 if: #left -> type == 'pair'; #left = #left -> name; /if; if: #right -> type == 'pair'; #right = #right -> name; /if; if: #left -> size > 1 && #right -> size > 1; if: #left -> (get: 1) == 'å' && #right -> (get: 1) == 'ä'; return: 0; else: #left -> (get: 1) == 'ä' && #right -> (get: 1) == 'å'; return: -1; /if; /if; return: (#left > #right ? -1 | 0); /define_tag; ]
No comments
©LassoSoft Inc 2015 | Web Development by Treefrog Inc | Privacy | Legal terms and Shipping | Contact LassoSoft