return Double.compare (start1, start2);
}
} );
ArrayList roots = new ArrayList (orderedByStart);
THashMap children = new THashMap ();
for (int i = 0; i < orderedByStart.size(); i++) {
LabeledSpan child = (LabeledSpan) orderedByStart.get (i);
for (int j = i-1; j >= 0; j--) {
LabeledSpan parent = (LabeledSpan) orderedByStart.get (j);
if (parent.isSubspan (child)) {
List childList = (List) children.get (parent);
if (childList == null) {
childList = new ArrayList ();
children.put (parent, childList);
}
roots.remove (child);
childList.add (child);
break;
}