{"id":34,"date":"2008-06-27T10:11:00","date_gmt":"2008-06-27T15:11:00","guid":{"rendered":"http:\/\/thaylin.info\/blog\/?p=34"},"modified":"2009-02-10T12:02:22","modified_gmt":"2009-02-10T17:02:22","slug":"a-quick-note","status":"publish","type":"post","link":"https:\/\/www.thaylin.com\/blog\/2008\/06\/27\/a-quick-note\/","title":{"rendered":"A quick note."},"content":{"rendered":"<p>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 <a href=\"http:\/\/frankfenghua.blogspot.com\/2007\/08\/removing-duplicate-items-from-array.html\">this post<\/a><\/p>\n<p>Granted it&#8217;s a little specific to what you want to sort but I&#8217;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.<\/p>\n<pre lang=\"actionscript\" line=\"1\" colla=\"+\">\r\nprivate function makeRegionList(myMapItemsArr:Array = null):Array {\r\n   var tempArr:Array = myMapItemsArr;\r\n   var keys:Object = {};\r\n   var tempArr2:Array = tempArr.filter(function(item:Object, idx:uint, arr:Array):Boolean {\r\n                        if (keys.hasOwnProperty(item.regionCode)) {\r\n                                        \/* If the keys Object already has this property, return false and discard this item. *\/\r\n                                        return false;\r\n                                    } else {\r\n                                        \/* Else the keys Object does *NOT* already have this key, so add this item to the new data provider. *\/\r\n                                        keys[item.regionCode] = item;\r\n                                        return true;\r\n                    \r\n                                    }\r\n                        })\r\n    return tempArr2\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>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&#8217;s a little specific to what you want to sort but I&#8217;m sure with a little change you could sort based on the function call maybe. I [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[11,9,8],"tags":[],"_links":{"self":[{"href":"https:\/\/www.thaylin.com\/blog\/wp-json\/wp\/v2\/posts\/34"}],"collection":[{"href":"https:\/\/www.thaylin.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.thaylin.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.thaylin.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.thaylin.com\/blog\/wp-json\/wp\/v2\/comments?post=34"}],"version-history":[{"count":1,"href":"https:\/\/www.thaylin.com\/blog\/wp-json\/wp\/v2\/posts\/34\/revisions"}],"predecessor-version":[{"id":115,"href":"https:\/\/www.thaylin.com\/blog\/wp-json\/wp\/v2\/posts\/34\/revisions\/115"}],"wp:attachment":[{"href":"https:\/\/www.thaylin.com\/blog\/wp-json\/wp\/v2\/media?parent=34"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.thaylin.com\/blog\/wp-json\/wp\/v2\/categories?post=34"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.thaylin.com\/blog\/wp-json\/wp\/v2\/tags?post=34"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}