summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/genie/src/base/iter.lua
blob: 0693ca73fbc9958acdc788f14999e1e74c65ed40 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
iter = {}

-- sortByKeys iterates over the table where the keys are in sort order
	
	function iter.sortByKeys(arr, f)
		local a = table.keys(arr)
		table.sort(a, f)
		
		local i = 0
		return function()
			i = i + 1
			if a[i] ~= nil then 
				return a[i], arr[a[i]]
			end
		end
	end