in reply to sorting question

Thank you all for helping me out. Immediately after I submitted my question, I browse through this site and came across some code snippet that is currently working for me. Here is what I have done:
#!/usr/bin/perl while (<>) { $str .= $_; } @lines = split ("\n", $str); @sorted = sort fooSort @lines; foreach $line (@sorted) { print ("$line\n"); } sub fooSort { my @a = split '\|', $a; my @b = split '\|', $b; $a[0] cmp $b[0] || $b[1] <=> $a[1] }
The above achieves what I wanted.
I will also try out some of the suggestions given by others. Thank you again for your help.

regards,
vincent