### Question:
Int2LongOpenHashMapWritable extends Int2LongOpenHashMap implements Writable { public Int2LongMap.Entry[] getEntriesSortedByValue() { if (this.size() == 0) return null; Int2LongMap.Entry[] entries = new Int2LongMap.Entry[this.size()]; entries = this.int2LongEntrySet().toArray(entries); Arrays.sort(entries, new Comparator<Int2LongMap.Entry>() { public int compare(Int2LongMap.Entry e1, Int2LongMap.Entry e2) { if (e1.getLongValue() > e2.getLongValue()) { return -1; } else if (e1.getLongValue() < e2.getLongValue()) { return 1; } if (e1.getIntKey() == e2.getIntKey()) return 0; return e1.getIntKey() > e2.getIntKey() ? 1 : -1; } }); return entries; } Int2LongOpenHashMapWritable(); void readFields(DataInput in); void decode(); boolean hasBeenDecoded(); void write(DataOutput out); byte[] serialize(); static Int2LongOpenHashMapWritable create(DataInput in); static Int2LongOpenHashMapWritable create(byte[] bytes); void plus(Int2LongOpenHashMapWritable m); long dot(Int2LongOpenHashMapWritable m); void increment(int key); void increment(int key, long n); static void setLazyDecodeFlag(boolean b); static boolean getLazyDecodeFlag(); int[] getKeys(); long[] getValues(); void lazyplus(Int2LongOpenHashMapWritable m); Int2LongMap.Entry[] getEntriesSortedByValue(); Int2LongMap.Entry[] getEntriesSortedByValue(int k);  }### Answer:
@Test public void testSortedEntries1() { Int2LongOpenHashMapWritable m = new Int2LongOpenHashMapWritable(); m.put(1, 5L); m.put(2, 2L); m.put(3, 3L); m.put(4, 3L); m.put(5, 1L); Int2LongMap.Entry[] e = m.getEntriesSortedByValue(); assertEquals(5, e.length); assertEquals(1, e[0].getIntKey()); assertEquals(5L, e[0].getLongValue()); assertEquals(3, e[1].getIntKey()); assertEquals(3L, e[1].getLongValue()); assertEquals(4, e[2].getIntKey()); assertEquals(3L, e[2].getLongValue()); assertEquals(2, e[3].getIntKey()); assertEquals(2L, e[3].getLongValue()); assertEquals(5, e[4].getIntKey()); assertEquals(1L, e[4].getLongValue()); }
@Test public void testSortedEntries2() { Int2LongOpenHashMapWritable m = new Int2LongOpenHashMapWritable(); m.put(1, 5); m.put(2, 2); m.put(3, 3); m.put(4, 3); m.put(5, 1); Int2LongMap.Entry[] e = m.getEntriesSortedByValue(2); assertEquals(2, e.length); assertEquals(1, e[0].getIntKey()); assertEquals(5L, e[0].getLongValue()); assertEquals(3, e[1].getIntKey()); assertEquals(3L, e[1].getLongValue()); }
@Test public void testSortedEntries3() { Int2LongOpenHashMapWritable m = new Int2LongOpenHashMapWritable(); m.put(1, 5); m.put(2, 2); Int2LongMap.Entry[] e = m.getEntriesSortedByValue(5); assertEquals(2, e.length); assertEquals(1, e[0].getIntKey()); assertEquals(5L, e[0].getLongValue()); assertEquals(2, e[1].getIntKey()); assertEquals(2L, e[1].getLongValue()); }
@Test public void testSortedEntries4() { Int2LongOpenHashMapWritable m = new Int2LongOpenHashMapWritable(); Int2LongMap.Entry[] e = m.getEntriesSortedByValue(); assertTrue(e == null); }