Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: How to sort an array

by jarich (Curate)
on Jul 07, 2004 at 13:23 UTC ( [id://372377]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
       my @Data = (
             "1|someproject|active...",
             "2|somethingelse|finished..."
       );
    
  2. or download this
    #!/usr/bin/perl -wT
    use strict;
    ...
    1|2|7|4|5|6|7|8|9
    1|2|2|5|5|6|7|8|9
    1|2|6|7|5|6|7|8|9
    
  3. or download this
    my @fields = qw/id projname status submitdt assign_dt 
                    total complete_dt person dept closed_dt/;
    ...
        @hash{@fields} = split /\|/, $_;
        $_ = \%hash;
    }
    
  4. or download this
    print "The id of the project in Data[0] is $Data[0]{id}\n";
    
  5. or download this
    my @sorted = sort {$a->{projname} cmp $b->{projname}} @Data;
    
    ...
            my %temp = %$_;
            print "@temp{@fields}\n";
    }
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2024-03-19 02:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found