in reply to sorting using substrs of same string
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:
cheersforeach 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"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re2: sorting using substrs of same string
by dragonchild (Archbishop) on Sep 23, 2003 at 21:10 UTC |