in reply to sorting using substrs of same string

Dear all,

figured it out for myself, it was my last sentence that made me think about it more: "but it just doesn't seem to pass through the '||'..."

Re-reading the definition of the comparison operators, they return '0' for equivalence and the two strings being compared, though sorted, were never going to be equal, hence sort never fell through to the next level.

here's my solution:

foreach my $ref ( sort { substr($a,0,1) cmp substr($b,0,1) || substr($a,1) <=> substr($b,1) } keys %{$self->{'residues'}{$i}}){ print "$ref\t"; }
cheers
Sam

Replies are listed 'Best First'.
Re2: sorting using substrs of same string
by dragonchild (Archbishop) on Sep 23, 2003 at 21:10 UTC
    Cardboard Programmers are amazing, aren't they? :-)

    Well done.

    ------
    We are the carpenters and bricklayers of the Information Age.

    The idea is a little like C++ templates, except not quite so brain-meltingly complicated. -- TheDamian, Exegesis 6

    Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.