nashkab has asked for the wisdom of the Perl Monks concerning the following question:
ENDPOINT DISTRIBUTION_ID STATUS VMW `1781183799.31152' IC--- WX `1781183799.32206' BN1 `1781183799.32206' BN2 `1781183799.32206' CAU `1781183799.32206' IC--- BN3 `1781183799.32206' IC--- BN4 `1781183799.32206' IC--E BN5 `1781183799.32206' IC--- BN6 `1781183799.32206' IC--- BN7 `1781183799.32206' IC---
I want to read this file into an array :--
open(FILE,"file.txt") my @Records = <FILE>;
now i want to sort this array using sort function: i have used
my @Records = sort {lc($a) cmp lc($b)} @Records and my @Records = sort {$a cmp $b} @Records my @Records = sort { $a[0] cmp $b[0] } @Records
But its not giving me desired result I want the file like this:
BN1 `1781183799.32206' BN2 `1781183799.32206' BN3 `1781183799.32206' IC--- BN4 `1781183799.32206' IC--E BN5 `1781183799.32206' IC--- BN6 `1781183799.32206' IC--- BN7 `1781183799.32206' IC--- CAU `1781183799.32206' IC--- VMW `1781183799.31152' IC--- WX `1781183799.32206'
I want the sort based on the first column
Edit: g0n code tags and formatting
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Need Help! Two Dimentional Array Sorting
by ww (Archbishop) on Jan 03, 2008 at 04:17 UTC | |
|
Re: Need Help! Two Dimentional Array Sorting
by McDarren (Abbot) on Jan 03, 2008 at 04:03 UTC | |
by graff (Chancellor) on Jan 03, 2008 at 05:10 UTC | |
by johngg (Canon) on Jan 03, 2008 at 11:29 UTC | |
|
Re: Need Help! Two Dimentional Array Sorting
by starX (Chaplain) on Jan 03, 2008 at 04:18 UTC | |
|
Re: Need Help! Two Dimentional Array Sorting
by CountZero (Bishop) on Jan 03, 2008 at 07:10 UTC |