-- A helper function that removes empty numeric indexes in a table,-- so that the values are tightly packed like in a normal Lua table.-- equivalent to require("Module:table").compressSparseArrayreturnfunction(t)localhighest=0fornum,_inpairs(t)doiftype(num)=="number"andnum>0andnum<math.hugeandmath.floor(num)==numthenhighest=math.max(highest,num)endendlocalneed_to_compress=falsefori=1,highestdoift[i]==nilthenneed_to_compress=truebreakendendifnotneed_to_compressthen-- The previous algorithm always copied, which implicitly removed 'maxindex' (and other non-numeric keys).-- Some code calls next(val) to check for a value being present, which depends on 'maxindex' not being present,-- so remove it.t.maxindex=nilreturntelselocalret={}localindex=1fori=1,highestdoift[i]~=nilthenret[index]=t[i]index=index+1endendreturnretendend