Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TugboatEng on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

SORTING MATRIX IN PERL

Status
Not open for further replies.

truckcab

Automotive
Joined
Jul 28, 2008
Messages
58
Location
SE
Hi,
I have written some Perl scripts occasionally in order to facilitate my job as a CAE-engineer. Everytime I need to sort the results that I have stored in a matrix I have had to make the sorting myself i.e. using some subroutine. However, Id really, really would like to learn how to use the perl function sort. I have read about it at many places and also tried to get it working but I have never ever got it to work for me. Can anyone help me here?

Say that i have a matrix $matrix with $n rows and $m columns and that I want to sort the rows based on what is the number in the second column. How do I do this using teh Perl sort function?

I would be very grateful for any help here!

Best regards
Pierre



Live Long and Prosper !
 
And have a look at Python... might be a stronger scripting language for what you're doing.

Dan - Owner
URL]
 
Just do an internet search for perl sort 2d array - lots of hits

If you are working in perl, make sure you comment the code - it is one of those syntax rich languages where simple statements can be written in lots of different ways - depends on what languages you have used as to how you write the code. Cobol programmers will write perl differently from C programmers.

Re: Live long and Prosper: you may have to use the spaceship operator <=>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top