A quick note.
Posted By Thaylin on June 27, 2008
I was trying to determine a way to sort an array without all the for loops and that sort of business when I ran across this post
Granted it’s a little specific to what you want to sort but I’m sure with a little change you could sort based on the function call maybe. I implemented it for my map stuff and it worked out great for plucking out regions that items are on.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | private function makeRegionList(myMapItemsArr:Array = null):Array { var tempArr:Array = myMapItemsArr; var keys:Object = {}; var tempArr2:Array = tempArr.filter(function(item:Object, idx:uint, arr:Array):Boolean { if (keys.hasOwnProperty(item.regionCode)) { /* If the keys Object already has this property, return false and discard this item. */ return false; } else { /* Else the keys Object does *NOT* already have this key, so add this item to the new data provider. */ keys[item.regionCode] = item; return true; } }) return tempArr2 } |
Comments
Leave a Reply
Please note: Comment moderation is currently enabled so there will be a delay between when you post your comment and when it shows up. Patience is a virtue; there is no need to re-submit your comment.