The incoming file is in the form of account:data. In this case, the data are Y-SNPs.
I want to sort by value (SNPs) and return the key (account) with the data so that I can keep the two associated. This prints only the data. And doing a regular array sort on the second field doesn't work either.
#!/usr/bin/perl
@lines = <STDIN>;
chomp @lines;
foreach (@lines)
{
(@f) = split /:/,$_;
$h{$f[0]} = $f[1];
}
@s = map { [ $_, $h{$_} ] } sort values %h;
foreach (@s) {print "@$_\n"}