Log In  


Cart #qsortz_bc-0 | 2024-07-24 | Code ▽ | Embed ▽ | No License

Feature Overview

QSORTZ() Quick sort by z.

  • sorts by reference to z from the argument table.
  • See the code in the cart for the single value type QSORT() where table t is sorted by v.
  • This function consumes 76 Token.
tb={{id='a', z=1}, {id='b', z=2}, {id='c', z=1.5}, {id='d', z=-0.5}}

?'before sort',6
for i,v in pairs(tb) do
    ?v.id..':'..v.z
end

qsortz(tb,1,#tb)

?'\nafter sort'
for i,v in pairs(tb) do
    ?v.id..':'..v.z
end
--[[
before sort
a:1
b:2
c:1.5
d:-0.5

after sort
d:-0.5
a:1
c:1.5
b:2
]]



[Please log in to post a comment]