Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re: Unusual sorting requirements; comparing three implementations.

by moritz (Cardinal)
on Oct 24, 2012 at 17:11 UTC ( #1000670=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download

  1. or download this
    sub two_pass {
        my @sorted =
            sort { $a->name cmp $b->name }
  2. or download this
                Rate    obvious     subtle   two_pass functional
    obvious    173/s         --       -22%       -30%       -61%
    subtle     222/s        28%         --       -11%       -50%
    two_pass   249/s        44%        12%         --       -44%
    functional 444/s       156%       100%        79%         --
  3. or download this
    use v6;
    class Person {
    say .perl for @sorted;
  4. or download this => "Alice", title => "Sales Manager") => "Carol", title => "Marketing Manager")
    ... => "Dave", title => "Janitor") => "Eve", title => "Tech Support") => "Fred", title => "Receptionist")

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1000670]
[LanX]: I'm not calling for shooting Trump with a golf ball ;-)
[LanX]: this bullshit theater is distracting us from real issues
[choroba]: he will resign
LanX "I put lipstick on a pig,"
[erix]: it does seem to get out of hand -- but then again, it looks like that for months already :)

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (7)
As of 2017-08-18 13:04 GMT
Find Nodes?
    Voting Booth?
    Who is your favorite scientist and why?

    Results (301 votes). Check out past polls.