Flasher Archive

[Previous] [Next] - [Index] [Thread Index] - [Previous in Thread] [Next in Thread]


Subject: FLASH: Array.sort() performance?
From: Daryn Nakhuda
Date: Wed, 20 Dec 2000 19:53:51 GMT


I'm using the built-in sort method to sort an array. I'm using a helper
function to make it case-insensitive, something like (i'm paraphrasing so
don't worry about my syntax/typos here)

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


myarray.sort(helper);


ANYHOW, performance seems to really dog when the array gets large (more
than a few hundred items)..

has anyone else seen this? It's possibly that I'm running up against
limitations in flash, and of course the performance will vary based on the
client machine, but I'm also guessing that the built-in implementation of
the sort algorithm may be sub-optimal...

When I put trace lines in the sort helper, you can watch the comparisions,
and it looks like it's either bubbling or something similar, definitly
looks O(n^2).

Have any of you implemented better sort algorithms in flash5 that you'd be
willing to share?



Thanks,

Daryn




~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
flasher is generously supported by...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
flashforward2000 and the Flash(tm) Film Festival
November 27-29, 2000, LONDON, National Film Theatre

Produced by United Digital Artists and lynda.com
-Sponsored by Macromedia, Adobe Systems and Apple Computer
-http://www.flashforward2000.com or UK tel. +44 (0870) 751 1526
Register before November 10 and save �200
http:// www.flashforward2000.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To unsubscribe or change your list settings go to
http://www.chinwag.com/flasher or email helpatchinwag [dot] com


Replies
  FLASH: Spinning Globe, Flash Gordon
  Re: FLASH: Array.sort() performance?, Helen Triolo

[Previous] [Next] - [Index] [Thread Index] - [Next in Thread] [Previous in Thread]