| Public Scratchpad | Download, Select Code To D/L |
It's a vary simple solution, it sorts based on the first number in (), I hope that there are no () signs before the third column.
Unfortunately, this does not work for the same index number repeated more then once. If I find some time, I'll try to find a better solution. Until then, maybe this will help. Feel free to ask any questions.
#!/usr/bin/perl -w use strict; use Data::Dumper; my %lines; while (<DATA>) { / \( # find the first ( sign (\d+) # then, capture the number in the brackets /x; $lines{$1} = $_; } #print Dumper %lines; for (sort {$a <=> $b} keys %lines) { print $lines{$_}; } __DATA__ 1opj-A 100.0 M309(67)* F401(159)* Y340(85) 2hyy-A 99.2 F382(147)* M290(55)* M309(67) 2pl0-A 48.3 Y318(88)* F383(159)* 1xbb-A 42.0 L501(134)* A400(38)* 1t46-A 39.4 K623(59)* M309(67)* 2oiq-A 48.9 M314(59)* Y340(85)*
The output:
2oiq-A 48.9 M314(59)* Y340(85)* 1opj-A 100.0 M309(67)* F401(159)* Y340(85) 2pl0-A 48.3 Y318(88)* F383(159)* 1xbb-A 42.0 L501(134)* A400(38)* 2hyy-A 99.2 F382(147)* M290(55)* M309(67)