in reply to sorting headers in a file
Hi utpalmtbi,
I agree totally with the advice of usage of some kind of database as mentioned by hdb.
However, using your dataset one can get his/her dirty using perl hash and a kind of "modified" Schwartzian transform like so:
NOTE:use warnings; use strict; my %hash; my $key; while (<DATA>) { next if /^\s+$/; if (/^>/) { $key = $_; } else { $hash{$key} = $_; } } print map { $_->[0], $hash{ $_->[0] }, $/ } sort { $a->[1] <=> $b->[1] } map { [ $_, /(\d+$)/ ] } keys %hash; __DATA__ >or3 agagatgatagat >or10 aacctttagtag >or1 gtatatatata >or2 tactacatgagg
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: sorting headers in a file
by hdb (Monsignor) on Dec 13, 2013 at 08:23 UTC | |
by 2teez (Vicar) on Dec 13, 2013 at 08:36 UTC | |
by hdb (Monsignor) on Dec 13, 2013 at 09:07 UTC |