Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

(tye)Re2: Efficiency in maintenance coding...

by tye (Sage)
on Nov 15, 2001 at 04:45 UTC ( [id://125477]=note: print w/replies, xml ) Need Help??


in reply to Re (tilly) 3: Efficiency in maintenance coding...
in thread Efficiency in maintenance coding...

No Schwartzian Transform is required. Does Java let you easily sort ignoring case? How about by length?...

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
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.

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")

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://125477]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (1)
As of 2024-04-24 16:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found