summaryrefslogtreecommitdiff
path: root/tex/context/base/l-table.lua
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2014-03-22 15:31:00 +0100
committerHans Hagen <pragma@wxs.nl>2014-03-22 15:31:00 +0100
commitc70b2e466bbb07e976f8684d56ae4e5398169e7d (patch)
treed644f87f32feeddcfb2de6e8ebe6667423eb0be4 /tex/context/base/l-table.lua
parent244a447d70f406e1341a56016564518013496a32 (diff)
downloadcontext-c70b2e466bbb07e976f8684d56ae4e5398169e7d.tar.gz
beta 2014.03.22 15:31
Diffstat (limited to 'tex/context/base/l-table.lua')
-rw-r--r--tex/context/base/l-table.lua38
1 files changed, 36 insertions, 2 deletions
diff --git a/tex/context/base/l-table.lua b/tex/context/base/l-table.lua
index c318c57bb..d231830ed 100644
--- a/tex/context/base/l-table.lua
+++ b/tex/context/base/l-table.lua
@@ -88,6 +88,38 @@ local function sortedkeys(tab)
end
end
+local function sortedhashonly(tab)
+ if tab then
+ local srt, s = { }, 0
+ for key,_ in next, tab do
+ if type(key) == "string" then
+ s = s + 1
+ srt[s] = key
+ end
+ end
+ sort(srt)
+ return srt
+ else
+ return { }
+ end
+end
+
+local function sortedindexonly(tab)
+ if tab then
+ local srt, s = { }, 0
+ for key,_ in next, tab do
+ if type(key) == "number" then
+ s = s + 1
+ srt[s] = key
+ end
+ end
+ sort(srt)
+ return srt
+ else
+ return { }
+ end
+end
+
local function sortedhashkeys(tab,cmp) -- fast one
if tab then
local srt, s = { }, 0
@@ -114,8 +146,10 @@ function table.allkeys(t)
return sortedkeys(keys)
end
-table.sortedkeys = sortedkeys
-table.sortedhashkeys = sortedhashkeys
+table.sortedkeys = sortedkeys
+table.sortedhashonly = sortedhashonly
+table.sortedindexonly = sortedindexonly
+table.sortedhashkeys = sortedhashkeys
local function nothing() end