in reply to Re^5: Sorting multi-dimensional arrays
in thread Sorting multi-dimensional arrays

The substr solution will work regardless of circumstances. . .

What about with CCI001 and CDI001? I think RMGir is right: the sort order is underspecified. Even something like:

# Simplified for illustration. Will not work for OP. Would benefit fro +m ST. sort { my ($a1,$a2) = $a =~ /([A-Z]*)(\d*)/; my ($b1,$b2) = $b =~ /([A-Z]*)(\d*)/; $a1 cmp $b1 || $a2 <=> $b2 } @list;
is likely to break with CC100A and CC100B. Given the elements that he gave us I'd think that a variation on the above would work but that guess isn't any better than yours or anyone's.

-sauoq
"My two cents aren't worth a dime.";

Replies are listed 'Best First'.
Re^7: Sorting multi-dimensional arrays
by Aristotle (Chancellor) on Sep 11, 2002 at 19:29 UTC
    Note that yours is making even fewer assumptions than mine, which makes fewer assumptions than cmp. Mine might be making too many assumptions - we can't tell. Your solution is better. The cmp on the other hand is very likely to be making too many assumptions. And that's what I was arguing - to make fewer assumptions.

    Makeshifts last the longest.