Skip to content

Instantly share code, notes, and snippets.

@AngeloYazar
Created October 13, 2012 04:28
Show Gist options
  • Save AngeloYazar/3883221 to your computer and use it in GitHub Desktop.
Save AngeloYazar/3883221 to your computer and use it in GitHub Desktop.
Sort a Corona SDK display group by y value.
local function depthSort( displayGroup )
local objects = {}
for i=1,displayGroup.numChildren do objects[#objects+1] = {displayGroup[i].y, displayGroup[i]} end
table.sort( objects, function(a,b) return a[1]<b[1] end )
for i=1,#objects do displayGroup:insert( objects[i][2] ) end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment