sorting display group elements

Hi,
I am trying to sort the elements contained in a display group (for isometric purpose) somehow I can’t? I have read the following article about table.sort() : http://developer.anscamobile.com/content/tables-arrays

and my attempt is:

[lua] local function sorting(a, b)
return a.y > b.y
end
local function enter_frame(event)
table.sort(game_group, sorting)
end
Runtime:addEventListener(“enterFrame”, enter_frame)
[/lua]
help? [import]uid: 11334 topic_id: 4202 reply_id: 304202[/import]

Old post, but I couldn’t find an answer, so I made this:

 local function sortSprites(localGroup)  
 local objetos = {}  
 for i=1,localGroup.numChildren do  
 objetos[#objetos+1]=localGroup[i]  
 end  
 table.sort(objetos,function(spr1,spr2) return spr1.y\>spr2.y end)  
 for k,spr in ipairs(objetos) do  
 spr:toFront()  
 end  
 end  

Hope this helps [import]uid: 99513 topic_id: 4202 reply_id: 79554[/import]