@Test
    public void shouldMaintainIndexOfTraversersAfterSort() {
        final IndexedTraverserSet<String, String> ts = makeOtherTraverserSet();

        final List<Traverser.Admin<String>> testTraversers = new ArrayList<>(ts.get("test"));
        assertEquals(1, testTraversers.size());
        assertEquals(4, testTraversers.get(0).bulk());

        final List<Traverser.Admin<String>> nopeTraversers = new ArrayList<>(ts.get("nope"));
        assertEquals(1, nopeTraversers.size());
        assertEquals(1, nopeTraversers.get(0).bulk());

        final List<Traverser<String>> traversersBefore = IteratorUtils.asList(ts.iterator());

        ts.sort(Comparator.comparing(Traverser::get));

        final List<Traverser<String>> traversersAfter = IteratorUtils.asList(ts.iterator());

        final List<Traverser.Admin<String>> testTraversersAfterSort = new ArrayList<>(ts.get("test"));
        assertEquals(1, testTraversersAfterSort.size());
        assertEquals(4, testTraversersAfterSort.get(0).bulk());

        final List<Traverser.Admin<String>> nopeTraversersAfterSort = new ArrayList<>(ts.get("nope"));
        assertEquals(1, nopeTraversersAfterSort.size());
        assertEquals(1, nopeTraversersAfterSort.get(0).bulk());

        assertNotEquals(traversersBefore, traversersAfter);
    }
@author Stephen Mallette (http://stephen.genoprime.com)
gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/util/IndexedTraverserSetTest.java