diff --git a/modules/Bio/EnsEMBL/VEP/Stats.pm b/modules/Bio/EnsEMBL/VEP/Stats.pm index 3287b7ee0..c371e7dfe 100644 --- a/modules/Bio/EnsEMBL/VEP/Stats.pm +++ b/modules/Bio/EnsEMBL/VEP/Stats.pm @@ -742,7 +742,13 @@ sub sort_keys { # sort data if(defined($sort)) { if($sort eq 'chr') { - @keys = sort {($a !~ /^\d+$/ || $b !~ /^\d+/ || $a =~ /^\d\w/ || $b =~ /^\d\w/ ) ? $a cmp $b : $a <=> $b} keys %{$data}; + @keys = sort { + (my $aterm = $a) =~ s/chr//; + (my $bterm = $b) =~ s/chr//; + $aterm = ord($aterm) unless $aterm =~ /^\d+$/; + $bterm = ord($bterm) unless $bterm =~ /^\d+$/; + return $aterm <=> $bterm; + } keys %{$data}; } elsif($sort eq 'value') { @keys = sort {$data->{$a} <=> $data->{$b}} keys %{$data};