Use proper unicode collation for sorting strings, and make the w/collation-key public

db4
Doug Coleman 2010-09-21 00:03:03 -05:00
parent 140aa80379
commit 7c161e274c
2 changed files with 2 additions and 4 deletions

View File

@ -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@

View File

@ -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 ;