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

Re: Remembering original order of an array

by menolly (Hermit)
on Sep 04, 2007 at 20:33 UTC ( [id://637022]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    @numbers = (1,2,3,4,5,6,7);
    @words = ('one', 'two', 'three', 'four', 'five', 'six', 'seven');
    @odd_even = ('odd', 'even', 'odd', 'even', 'odd', 'even', 'odd');
    @prime = ('not', 'prime', 'prime', 'not', 'prime', 'not', 'prime');
    
  2. or download this
    @numbers_with_attributes = ( [1, 'one', 'odd', 'not'], 
                                 [2, 'two', 'even', 'prime'],
    ...
                                 [7, 'seven', 'odd', 'prime'],
                               );
    @alpha_sort = sort { $a[1] cmp $b[1] } @numbers_with_attributes;
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2024-04-19 12:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found