libs/core: make luci.util.spairs(), kspairs() and vspairs() return the sequential index as 3rd variable
This commit is contained in:
parent
9297ef38c4
commit
33fba71fc9
1 changed files with 2 additions and 4 deletions
|
@ -4,9 +4,6 @@ LuCI - Utility library
|
||||||
Description:
|
Description:
|
||||||
Several common useful Lua functions
|
Several common useful Lua functions
|
||||||
|
|
||||||
FileId:
|
|
||||||
$Id$
|
|
||||||
|
|
||||||
License:
|
License:
|
||||||
Copyright 2008 Steven Barth <steven@midlink.org>
|
Copyright 2008 Steven Barth <steven@midlink.org>
|
||||||
|
|
||||||
|
@ -609,6 +606,7 @@ end
|
||||||
function _sortiter( t, f )
|
function _sortiter( t, f )
|
||||||
local keys = { }
|
local keys = { }
|
||||||
|
|
||||||
|
local k, v
|
||||||
for k, v in pairs(t) do
|
for k, v in pairs(t) do
|
||||||
keys[#keys+1] = k
|
keys[#keys+1] = k
|
||||||
end
|
end
|
||||||
|
@ -620,7 +618,7 @@ function _sortiter( t, f )
|
||||||
return function()
|
return function()
|
||||||
_pos = _pos + 1
|
_pos = _pos + 1
|
||||||
if _pos <= #keys then
|
if _pos <= #keys then
|
||||||
return keys[_pos], t[keys[_pos]]
|
return keys[_pos], t[keys[_pos]], _pos
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue