### Question:
StreamSourceMeshy extends AbstractPersistentStreamSource { int compareStreamFiles(final MeshyStreamFile streamFile1, final MeshyStreamFile streamFile2) { if (streamFile1.equals(streamFile2)) { return 0; } final String n1 = getSortOffset(streamFile1.name()); final String n2 = getSortOffset(streamFile2.name()); int c = n1.compareTo(n2); if (c == 0) { c = streamFile1.name().compareTo(streamFile2.name()); } if (c == 0) { c = Integer.compare(streamFile1.hashCode(), streamFile2.hashCode()); } return c; }  @Override StreamFile nextSource(); @Override void doShutdown(); DateTime getFirstDate(); DateTime getLastDate(); void setFirstDate(DateTime date); void setLastDate(DateTime date);  }### Answer:
@Test public void testStreamSourcesSort() { final StreamSourceMeshy source = new StreamSourceMeshy(); final int numElements = 100000; FileReference[] fileRefs = new FileReference[numElements]; List<MeshyStreamFile> streamFiles = new ArrayList<>(numElements); DateTime date = DateTime.now(); try { for (int i = 0; i < numElements; i++) { fileRefs[i] = new FileReference("", 0, i); Field f = fileRefs[i].getClass().getDeclaredField("hostUUID"); f.setAccessible(true); String uuid = RandomStringUtils.randomAlphabetic(20); f.set(fileRefs[i], uuid); streamFiles.add(new MeshyStreamFile(source, date, fileRefs[i])); } } catch (Exception ex) { ex.printStackTrace(); fail(); } Collections.shuffle(streamFiles); Collections.sort(streamFiles, new Comparator<MeshyStreamFile>() { @Override public int compare(MeshyStreamFile streamFile1, MeshyStreamFile streamFile2) { return source.compareStreamFiles(streamFile1, streamFile2); } }); }