[Bioperl-l] New Bioperl dependency? Sort::Naturally

Florent Angly florent.angly at gmail.com
Sat May 8 04:42:18 UTC 2010


Hi all,

I am working on updating some of the Bio::Assembly::* modules right now.
I need to sort a list of IDs. These IDs could be numbers, "words" or a 
mix of the two, for example:         @arr = ('singlet1', 'contig10', 
'contig2',  '101', '3');

I cannot sort them with the numerical sort: sort { $a <=> $b } @array
This would generates warnings because some of'singlet1' the IDs are numbers.

I cannot sort them lexically: sort @array
Lexical sorting would not take into account numbers properly and result in:
     singlet1 contig10 contig2 3 101

So, what I really need is natural sorting, which is not in any core 
function of Perl. I'd like to use the CPAN module Sort::Naturally for 
this purpose: nsort @arr
The results would be what we expect, i.e.:
     3 101 contig2 contig10 singlet1

Can I add this module as an additional dependency of BioPerl? I imagine 
that some other modules might want to use this. On the assembly side, it 
would be used by the writing methods of Bio::Assembly::IO::tigr and ace. 
Or maybe there is an easy way around my problem that doesn't require any 
external module?

Florent



More information about the Bioperl-l mailing list