ArtistIndexService { protected Comparator<String> getIndexComparator() { return new Comparator<String>() { @Override public int compare(String s1, String s2) { if (s1.equals(HASH_STR) && s2.equals(HASH_STR)) { return 0; } else if (s1.equals(HASH_STR)) { return 1; } else if (s2.equals(HASH_STR)) { return -1; } else { return s1.compareTo(s2); } } }; }  Map<String, List<Artist>> getIndexedArtists(List<Artist> artists); SortedMap<String, List<Artist>> getIndexedArtists(List<Integer> indexes, String indexLetter, List<Artist> artists); void setSettingsService(SettingsService settingsService);  }
@Test public void sortsIndexButPutsHashLast() { List<String> index = new ArrayList<String>(); index.add("A"); index.add("#"); index.add("C"); index.add("B"); Collections.sort(index, artistIndexService.getIndexComparator()); Assert.assertEquals("A", index.get(0)); Assert.assertEquals("B", index.get(1)); Assert.assertEquals("C", index.get(2)); Assert.assertEquals("#", index.get(3)); }