No Schwartzian Transform is required. Does Java let you easily sort ignoring case? How about by length?...
You might find that a ST executes faster for that second case (and you could almost certainly speed it up with one of several techniques that are faster in Perl than an ST), but I doubt the speed gain would be worthwhile since lc() shouldn't be that slow.sort { $freq{$a} <=> $freq{$b} } keys %freq sort { lc($a) cmp lc($b) || $a cmp $b } keys %freq sort { length($a) <=> length($b) || lc($a) cmp lc($b) || $a cmp $b } keys %freq
Speeding up the third case with a ST would be more difficult than using some other sort-speeding techniques (many of which have names that I don't recall). Though you'd have to have a whole lot of different words for the trade off of sort speed for code complexity to be a "win" here, especially since we are trying to write very maintainable code.
- tye (but my friends call me "Tye")In reply to (tye)Re2: Efficiency in maintenance coding...
by tye
in thread Efficiency in maintenance coding...
by eduardo
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |