Beefy Boxes and Bandwidth Generously Provided by pair Networks Cowboy Neal with Hat
Welcome to the Monastery
 
PerlMonks  

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 }
            @employees;
    }
    
  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 {
    ...
        .sort.map(*.value.sort(*.name));
    
    say .perl for @sorted;
    
  4. or download this
    Person.new(name => "Alice", title => "Sales Manager")
    Person.new(name => "Carol", title => "Marketing Manager")
    ...
    Person.new(name => "Dave", title => "Janitor")
    Person.new(name => "Eve", title => "Tech Support")
    Person.new(name => "Fred", title => "Receptionist")
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (13)
As of 2014-04-17 19:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (454 votes), past polls