Joseph Canedo <mailto:josephcan...@gmail.com>
30. Juli 2016 um 15:04
If the requirement is to iterate on a table having the keys, values
sorted by key (assuming the keys can be sorted), there are ways to do
this. Please see http://lua-users.org/wiki/SortedIteration for an
example (this just replaces pairs(t) with orderedPairs(t)).
\starttext
\startluacode
local testtable = { z = "A", y = "B", x = "C" }
for i, j in next, testtable do
context("%s:%s",i,j)
context.par()
end
context.blank()
for i, j in table.sortedhash(testtable) do
context("%s:%s",i,j)
context.par()
end
\stopluacode
\stoptext
Wolfgang
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the
Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://tex.aanhet.net
archive : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________