
November 11th, 2008, 07:40 PM
|
 |
Contributing User
|
|
Join Date: May 2006
Location: England
|
|
Quote: | Originally Posted by Jason Knight I have an array of objects that I need to sort by their property xpos. I then need to set the zindex property of the object in order of xpos from lowest to highest. | Assuming xpos is an integer:
Code:
myArray.sort( function(a, b){return a.xpos - b.xpos} );
for(var i=0; i<myArray.length; i++)
myArray[i].zIndex=i;
__________________
No it's not 'awesome' - it's just code.
|