in reply to Sorting strings
Since the number of right-padded with zeroes, sorting in plain old lexical order will do the trick.
my @unsorted = ( '>ENSP00000314624 GCACAATGGTAGAGGCAGATCATCC', '>ENSP00000347089 ATGGATTGCTGTGCCTCTCGAGGCT', '>ENSP00000301587 TGACCCACTTCCGTTACTTGCTGCG', ); my @sorted = sort @unsorted; print("$_\n") foreach @sorted;
Ref: sort
Update: My post was written when the OP wasn't formatted. It wasn't evidentant that there were line breaks in the data. The answer is still the same, however. The key is to create an array of records instead of an array of lines. mreece shows one way of doing this.
|
|---|