N
Nath
I have an array of arrays:
my $output_aln_types = [
['Clustal', '.aln'],
['NEXUS', ['.nex', '.nexus']],
['Phylip', [ '.phy', '.phylip', '.phlp', '.phyl', '.phy', '.ph' ]],
['FASTA', [ '.fas', '.fasta', '.fast', '.seq', '.fa', '.fsa',
'.nt', '.aa' ] ],
['MEGA', [ '.meg', '.mega' ]],
['User Defined', '*.*'],
];
I want to sort it so that it is alphabetical, BUT with 'NEXUS' first, and
'User Defined' last. the sort should return the following array of arrays:
my $output_aln_types = [
['NEXUS', ['.nex', '.nexus']],
['Clustal', '.aln'],
['FASTA', [ '.fas', '.fasta', '.fast', '.seq', '.fa', '.fsa',
'.nt', '.aa' ] ],
['MEGA', [ '.meg', '.mega' ]],
['Phylip', [ '.phy', '.phylip', '.phlp', '.phyl', '.phy', '.ph' ]],
['User Defined', '*.*'],
];
i can use the following subroutine to sort alphabetically, but don't know
how to place the 2 conditions of 'NEXUS' first, and 'User Defined' last:
@$output_aln_types = sort { $a->[0] cmp $b->[0] } @$output_aln_types;
Thanks
Nathan
my $output_aln_types = [
['Clustal', '.aln'],
['NEXUS', ['.nex', '.nexus']],
['Phylip', [ '.phy', '.phylip', '.phlp', '.phyl', '.phy', '.ph' ]],
['FASTA', [ '.fas', '.fasta', '.fast', '.seq', '.fa', '.fsa',
'.nt', '.aa' ] ],
['MEGA', [ '.meg', '.mega' ]],
['User Defined', '*.*'],
];
I want to sort it so that it is alphabetical, BUT with 'NEXUS' first, and
'User Defined' last. the sort should return the following array of arrays:
my $output_aln_types = [
['NEXUS', ['.nex', '.nexus']],
['Clustal', '.aln'],
['FASTA', [ '.fas', '.fasta', '.fast', '.seq', '.fa', '.fsa',
'.nt', '.aa' ] ],
['MEGA', [ '.meg', '.mega' ]],
['Phylip', [ '.phy', '.phylip', '.phlp', '.phyl', '.phy', '.ph' ]],
['User Defined', '*.*'],
];
i can use the following subroutine to sort alphabetically, but don't know
how to place the 2 conditions of 'NEXUS' first, and 'User Defined' last:
@$output_aln_types = sort { $a->[0] cmp $b->[0] } @$output_aln_types;
Thanks
Nathan