@Test
    public void testSortRecursive() {
        AlternateSpanList root = new AlternateSpanList();
        Span a1 = new Span(0, 1);
        SpanList b1 = new SpanList();
        SpanList c1 = new SpanList();
        Span d1 = new Span(9, 1);
        root.add(d1).add(c1).add(a1).add(b1);

        Span aB2 = new Span(1, 1);
        Span bB2 = new Span(2, 1);
        Span cB2 = new Span(3, 1);
        Span dB2 = new Span(4, 1);
        b1.add(dB2).add(cB2).add(bB2).add(aB2);

        Span aC2 = new Span(5, 1);
        Span bC2 = new Span(6, 1);
        Span cC2 = new Span(7, 1);
        Span dC2 = new Span(8, 1);
        c1.add(cC2).add(aC2).add(bC2).add(dC2);

        Span altA1 = new Span(0, 1);
        Span altB1 = new Span(1, 1);
        List<SpanNode> altList = new ArrayList<>(2);
        altList.add(altB1);
        altList.add(altA1);
        root.addChildren(1, altList, 0.5);

        root.sortChildrenRecursive();
        assertSame(a1, root.children().get(0));
        assertSame(b1, root.children().get(1));
        assertSame(c1, root.children().get(2));
        assertSame(d1, root.children().get(3));
        assertSame(aB2, b1.children().get(0));
        assertSame(bB2, b1.children().get(1));
        assertSame(cB2, b1.children().get(2));
        assertSame(dB2, b1.children().get(3));
        assertSame(aC2, c1.children().get(0));
        assertSame(bC2, c1.children().get(1));
        assertSame(cC2, c1.children().get(2));
        assertSame(dC2, c1.children().get(3));

        assertSame(altA1, root.children(1).get(0));
        assertSame(altB1, root.children(1).get(1));
    }
@author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a>
document/src/test/java/com/yahoo/document/annotation/AlternateSpanListTestCase.java