in reply to Sorting strings

you can set the input record separator to \n\n to read the paragraph format you have there. then the default sort will work, if the prefix is the same on every line.
#!perl use strict; use warnings; my @data; { local $/ = "\n\n"; @data = <DATA>; } my @sorted = sort @data; print @sorted; __DATA__ >ENSP00000314624 GCACAATGGTAGAGGCAGATCATCC >ENSP00000347089 ATGGATTGCTGTGCCTCTCGAGGCT >ENSP00000301587 TGACCCACTTCCGTTACTTGCTGCG
produces
>ENSP00000301587
TGACCCACTTCCGTTACTTGCTGCG

>ENSP00000314624
GCACAATGGTAGAGGCAGATCATCC

>ENSP00000347089
ATGGATTGCTGTGCCTCTCGAGGCT

Replies are listed 'Best First'.
Re^2: Sorting strings
by uvnew (Acolyte) on Jan 26, 2007 at 12:55 UTC
    Thanks a lot, that works perfectly! Can you recommend a good tutorial for regular expressions? I think I really need that... Cheers, uv