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