Hi,
I have a file in the following format:
Now I'm converting the file to an array and then I'm splitting the fields. I would to sort the array by the "FIELD2".
The array is not getting sorted properly with my current data.
I have a file in the following format:
Code:
FIELD1|FIELD2|FIELD3|FIELD4
1|90-09|LINK|A-D
2|05-09|LINK-PL|FDX
Now I'm converting the file to an array and then I'm splitting the fields. I would to sort the array by the "FIELD2".
Code:
open(FILE,"file.dat") || die("Error !")
@File = map {chomp; [split /\|/, $_]} <FILE>;
close(FILE);
sort { $b->[1] cmp $a->[1] } @File;
The array is not getting sorted properly with my current data.