Beefy Boxes and Bandwidth Generously Provided by pair Networks vroom
No such thing as a small change
 
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
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 perusing the Monastery: (8)
As of 2014-04-20 19:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (487 votes), past polls