Thanks for the reply. I've not used the Schwarztian Transform before so tend to shy away from it. However, I read a bit more about it and discovered that it won't work for my actual code which is an array of objects.
Your bucketsort is the elegant solution that I was seeking. Interesting though it's about twice as slow as my ugly version as indicated by this benchmark:
Benchmark: timing 500000 iterations of bucketsort, sort... bucketsort: 2 wallclock secs ( 1.72 usr + 0.00 sys = 1.72 CPU) @ 29 +0697.67/s (n=500000) sort: 0 wallclock secs ( 0.89 usr + 0.00 sys = 0.89 CPU) @ 56 +1797.75/s (n=500000) Rate bucketsort sort bucketsort 290698/s -- -48% sort 561798/s 93% --
Thanks
-Wm
In reply to Re: Re: Efficiently sorting array by non-alpha strings
by knowmad
in thread Efficiently sorting array by non-alpha strings
by knowmad
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |