[Extendflash] Case Insensitive Array sorting

Till Schneidereit zooey at gmx.net
Wed Jul 27 22:15:01 PDT 2005


> Just curious if anyone has done this already and is willing to share the code...
> 
> I'm looking for a function todo case insensitive array sorting in jsfl, no AS.
> 
> Thanks,
> Ryan

I didn't test this, but since jsfl runs in the Mozilla Foundation's SpiderMonkey JavaScript engine, the following should do just fine:

function sortCaseInsensitive(a, b) {
if (a.text.toLowerCase() < b.text.toLowerCase()) return -1;
if (a.text.toLowerCase() > b.text.toLowerCase()) return 1;
return 0;
}

To sort an array using this function:
mySortedArray = myArray.sort (sortCaseInsensitive);

cheers,
till


More information about the Extendflash mailing list