Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: sorting the column of array element

by sauoq (Abbot)
on May 24, 2012 at 00:11 UTC ( #972132=note: print w/ replies, xml ) Need Help??


in reply to sorting the column of array element

Hi, I am trying to sort the zeroth array element

By this do you mean that your $array[0] is a reference to an array?

If so, you want something like

@sort = sort {$b <=> $a} @{ $array[0] };

-sauoq
"My two cents aren't worth a dime.";


Comment on Re: sorting the column of array element
Select or Download Code
Replies are listed 'Best First'.
Re^2: sorting the column of array element
by anonym (Acolyte) on May 24, 2012 at 00:14 UTC

    Hey Thanks.. Yes $array[0] is one column of a tab delimited file having three columns.so i wanna sort on the first column Thanks

      Ummmmm..... it seems to me that either your answer, "yes," to the question whether @array[0] 'is a reference to an array?'
      • is inaccurate (eg, 'wrong')
             . ... or else
      • @array[0] is something other than the simple content of 'one column of a tab delimited file having three columns' (where the 'simple content' is something sortable -- either numericly or alphabetically -- without further specification of the criteria for sorting).

      Which is it?

      Update: Added quoted content in second bullet, for clarity and closing paren for correctness. Duh!

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (9)
As of 2015-07-30 05:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (270 votes), past polls