[Biojava-l] Sort Features

Thomas Down td2 at sanger.ac.uk
Wed Jan 11 06:08:11 EST 2006


On 11 Jan 2006, at 10:45, Christian Köberle wrote:

> Hi,
>
> exists a way to get Features from a FeatureHolder sorted  by Location?

You guarantee a specific iteration order from a FeatureHolder (unless  
you write your own implementation).  You can, however, dump some  
features into a List or Set then sort them there.

           FeatureHolder fh = ...;
           List l = new ArrayList();
           for (Iterator i = fh.features(); i.hasNext(); ) {
               l.add(i.next());
           }
           Collections.sort(l, Feature.byLocationOrder);


Thomas.


More information about the Biojava-l mailing list