Module:TableTools: Difference between revisions
Jump to navigation
Jump to search
imported>Pppery Implementing merger with Module:Table |
MeowyCats2 (talk | contribs) m 59 revisions imported |
||
(13 intermediate revisions by 12 users not shown) | |||
Line 304: | Line 304: | ||
]] | ]] | ||
function p.sortedPairs(t, keySort) | function p.sortedPairs(t, keySort) | ||
checkType('sortedPairs', 1, t, 'table') | checkType('sortedPairs', 1, t, 'table') | ||
checkType('sortedPairs', 2, keySort, 'function', true) | checkType('sortedPairs', 2, keySort, 'function', true) | ||
Line 427: | Line 426: | ||
-- a different value when there are gaps in the array portion of the table. | -- a different value when there are gaps in the array portion of the table. | ||
-- Intended to be used on data loaded with mw.loadData. For other tables, use #. | -- Intended to be used on data loaded with mw.loadData. For other tables, use #. | ||
-- Note: #frame.args in frame object always be set to 0, regardless of | |||
-- the number of unnamed template parameters, so use this function for | |||
-- frame.args. | |||
--]] | --]] | ||
function p.length(t) | function p.length(t) | ||
local i = | local i = 1 | ||
while t[i] ~= nil do | |||
i = i + 1 | i = i + 1 | ||
end | |||
return i - 1 | return i - 1 | ||
end | end |