help with sorting
Posted: Tue Apr 01, 2014 9:06 pm
I'm working on a pseudo 3d system, where objects have x,y, and z coordinates. When I draw them on screen, I want to draw stuff with lower x, y, and z values first, and stuff with higher x, y, and z values last. How can I sort objects based on their values?
Or rather, is there a pre-existing version of table.sort I can use, or do I have to make a custom sorting function?
exampleTable={
{"item1", x=0,y=1,z=1},
{"item2", x=5,y=1,z=1},
{"item3", x=0,y=7,z=1}
}
and I'd draw items using something like
for i=1,#exampleTable do
draw(exampleTable)
end
Or rather, is there a pre-existing version of table.sort I can use, or do I have to make a custom sorting function?
exampleTable={
{"item1", x=0,y=1,z=1},
{"item2", x=5,y=1,z=1},
{"item3", x=0,y=7,z=1}
}
and I'd draw items using something like
for i=1,#exampleTable do
draw(exampleTable)
end