I have an array whose strings are flatfile db lines.
The first part of each $ looks like this: 12,456|L|etc.
It is a number followed by pipe(|)delimiters and other junk.
I am trying to sort this array by the first one or two #'s, so here is what I have:
@stupidperl = sort {($a =~ /^\d\d?/) <=> ($b =~ /^\d\d?/)} @stupidperl;
this should pull the first one or two digits of the string and sort by them numerically, but it fails to do so. I don't get it. PLEASE HELP ME. I AM SAD.
The first part of each $ looks like this: 12,456|L|etc.
It is a number followed by pipe(|)delimiters and other junk.
I am trying to sort this array by the first one or two #'s, so here is what I have:
@stupidperl = sort {($a =~ /^\d\d?/) <=> ($b =~ /^\d\d?/)} @stupidperl;
this should pull the first one or two digits of the string and sort by them numerically, but it fails to do so. I don't get it. PLEASE HELP ME. I AM SAD.