user2835809
user2835809

Reputation:

Sorting an object array in actionscript 3

I have an object array in AS3 and I would like to sort it based on their custom properties.

Is there an automatic way of sorting it or do I really have to define a function to do it? Any help??

Upvotes: 1

Views: 256

Answers (1)

Matt
Matt

Reputation: 1032

you can do this

var records:Array = new Array(); 

records.push({name:"john", city:"montreal", zip:63144}); 
records.push({name:"bob", city:"toronto", zip:66345}); 
records.push({name:"bob", city:"vancouver", zip:16010}); 

records.sortOn(["name", "city"]); 

trace("records.sortOn('city', 'name');"); 

Upvotes: 2

Related Questions