Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function pairsByKeys (t, f)
- local a = {}
- for n in pairs(t) do table.insert(a, n) end
- table.sort(a, f)
- local i = 0 -- iterator variable
- local iter = function () -- iterator function
- i = i + 1
- if a[i] == nil then return nil
- else return a[i], t[a[i]]
- end
- end
- return iter
- end
- t = load("dictionary")
- for name, line in pairsByKeys(t) do
- print(name, line)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement