[ t t f f ] [ "hello" "HELLO" test-equality ] unit-test\r
[ t t t f ] [ "hello" "h e l l o." test-equality ] unit-test\r
[ t t t t ] [ "hello" "\0hello\0" test-equality ] unit-test\r
+[ { "good bye" "goodbye" "hello" "HELLO" } ]\r
+[ { "HELLO" "goodbye" "good bye" "hello" } sort-strings ]\r
+unit-test\r
\r
parse-test 2 <clumps>\r
[ [ test-two ] assoc-each ] with-null-writer\r
0 insensitive= ;\r
\r
<PRIVATE\r
-: compare-collation ( {str1,key} {str2,key} -- <=> )\r
- 2dup [ second ] bi@ <=> dup +eq+ =\r
- [ drop <=> ] [ 2nip ] if ;\r
-\r
: w/collation-key ( str -- {str,key} )\r
- dup collation-key 2array ;\r
+ [ collation-key ] keep 2array ;\r
PRIVATE>\r
\r
: sort-strings ( strings -- sorted )\r
[ w/collation-key ] map\r
- [ compare-collation ] sort\r
- keys ;\r
+ natural-sort values ;\r
\r
: string<=> ( str1 str2 -- <=> )\r
- [ w/collation-key ] bi@ compare-collation ;\r
+ [ w/collation-key ] compare ;\r