diff options
author | Hans Hagen <pragma@wxs.nl> | 2010-02-15 22:16:00 +0100 |
---|---|---|
committer | Hans Hagen <pragma@wxs.nl> | 2010-02-15 22:16:00 +0100 |
commit | 3f2e64b7790558e460c65c2ea60e4eb3c6b5e0a9 (patch) | |
tree | 2db9554267e5ee0539fd6b0e708ade0b1431392b /tex/context/base/sort-ini.lua | |
parent | e3f0fbded1db3addc97fe1921f4957261c8a425f (diff) | |
download | context-3f2e64b7790558e460c65c2ea60e4eb3c6b5e0a9.tar.gz |
beta 2010.02.15 22:16
Diffstat (limited to 'tex/context/base/sort-ini.lua')
-rw-r--r-- | tex/context/base/sort-ini.lua | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/tex/context/base/sort-ini.lua b/tex/context/base/sort-ini.lua index 80607f9ca..e59759311 100644 --- a/tex/context/base/sort-ini.lua +++ b/tex/context/base/sort-ini.lua @@ -14,9 +14,11 @@ if not modules then modules = { } end modules ['sort-ini'] = { -- always expand to utf local utf = unicode.utf8 -local gsub, rep = string.gsub, string.rep +local gsub, rep, sort, concat = string.gsub, string.rep, table.sort, table.concat local utfcharacters, utfvalues, strcharacters = string.utfcharacters, string.utfvalues, string.characters +local trace_sorters = false -- true + sorters = { } sorters.comparers = { } sorters.splitters = { } @@ -145,5 +147,19 @@ function sorters.splitters.utf(str) -- brrr, todo: language end function sorters.sort(entries,cmp) - table.sort(entries,function(a,b) return cmp(a,b) == -1 end) + if trace_sorters then + sort(entries, function(a,b) + local r = cmp(a,b) + local as, bs = a.split, b.split + if as and bs then + logs.report("sorter","%s %s %s", + concat(as[1]), (not r and "?") or (r<0 and "<") or (r>0 and ">") or "=", concat(bs[1])) + end + return r == -1 + end) + else + sort(entries, function(a,b) + return cmp(a,b) == -1 + end) + end end |