Use proper unicode collation for sorting strings, and make the w/collation-key public
parent
140aa80379
commit
7c161e274c
|
@ -2,7 +2,7 @@
|
|||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: accessors fry kernel make math math.order math.parser
|
||||
sequences sorting.functor strings unicode.case
|
||||
unicode.categories ;
|
||||
unicode.categories unicode.collation ;
|
||||
IN: sorting.human
|
||||
|
||||
: cut-find ( seq pred -- before after )
|
||||
|
@ -33,7 +33,7 @@ TUPLE: hybrid obj ;
|
|||
|
||||
: <hybrid-insensitive> ( obj -- hybrid )
|
||||
hybrid new
|
||||
swap dup string? [ >case-fold ] when >>obj ; inline
|
||||
swap dup string? [ w/collation-key ] when >>obj ; inline
|
||||
|
||||
M: hybrid <=>
|
||||
[ obj>> ] bi@
|
||||
|
|
|
@ -149,10 +149,8 @@ PRIVATE>
|
|||
: quaternary= ( str1 str2 -- ? )
|
||||
0 insensitive= ;
|
||||
|
||||
<PRIVATE
|
||||
: w/collation-key ( str -- {str,key} )
|
||||
[ collation-key ] keep 2array ;
|
||||
PRIVATE>
|
||||
|
||||
: sort-strings ( strings -- sorted )
|
||||
[ w/collation-key ] map natural-sort values ;
|
||||
|
|
Loading…
Reference in New Issue