### Question:
SequenceAllocation implements Comparable<SequenceAllocation> { public SequenceKey getSequenceKey() { return sequenceKey; } SequenceAllocation(SequenceKey sequenceKey, long numAllocations); SequenceKey getSequenceKey(); long getNumAllocations(); @Override int hashCode(); @Override boolean equals(Object obj); @Override int compareTo(SequenceAllocation that);  }### Answer:
@Test public void testSortingSequenceAllocation() { SequenceKey sequenceKey1 = new SequenceKey(null, "seqalloc", "sequenceC",QueryServicesOptions.DEFAULT_SEQUENCE_TABLE_SALT_BUCKETS); SequenceKey sequenceKey2 = new SequenceKey(null, "seqalloc", "sequenceB",QueryServicesOptions.DEFAULT_SEQUENCE_TABLE_SALT_BUCKETS); SequenceKey sequenceKey3 = new SequenceKey(null, "seqalloc", "sequenceA",QueryServicesOptions.DEFAULT_SEQUENCE_TABLE_SALT_BUCKETS); List<SequenceKey> sequenceKeys = Lists.newArrayList(sequenceKey1, sequenceKey2, sequenceKey3); List<SequenceAllocation> sequenceAllocations = Lists.newArrayList(new SequenceAllocation(sequenceKey2, 1), new SequenceAllocation(sequenceKey1, 1), new SequenceAllocation(sequenceKey3, 1)); Collections.sort(sequenceKeys); Collections.sort(sequenceAllocations); int i = 0; for (SequenceKey sequenceKey : sequenceKeys) { assertEquals(sequenceKey, sequenceAllocations.get(i).getSequenceKey()); i++; } }