I have an array called @list with these elements:
31 BBB0094
31 BBB0096
20 BBB0094
31 AAA0091
31 AAA0093
10 AAA0091
10 BBB0091
20 AAA0091
20 AAA0092
I cannot figure out a perl way to sort the 1st column numerically while also sorting the second column by:
1) the first 3 alphas
then
2) the remaining numbers numerically
Here is my desired output:
10 AAA0091
10 BBB0091
20 AAA0091
20 AAA0092
20 BBB0094
31 AAA0091
31 AAA0093
31 BBB0094
31 BBB0096
Here is what i do now, using the unix sort command, which seems to work:
open(SORT, "| sort -n >>$final"
print SORT @list;
close SORT;
Any help would be appreciated. thanks,
-jim
31 BBB0094
31 BBB0096
20 BBB0094
31 AAA0091
31 AAA0093
10 AAA0091
10 BBB0091
20 AAA0091
20 AAA0092
I cannot figure out a perl way to sort the 1st column numerically while also sorting the second column by:
1) the first 3 alphas
then
2) the remaining numbers numerically
Here is my desired output:
10 AAA0091
10 BBB0091
20 AAA0091
20 AAA0092
20 BBB0094
31 AAA0091
31 AAA0093
31 BBB0094
31 BBB0096
Here is what i do now, using the unix sort command, which seems to work:
open(SORT, "| sort -n >>$final"
print SORT @list;
close SORT;
Any help would be appreciated. thanks,
-jim