BuildIdComparator implements Comparator<String> { @Override public int compare(String s1, String s2) { int comparison = 0; try { comparison = Integer.valueOf(s1).compareTo(Integer.valueOf(s2)); } catch (NumberFormatException e) { } return comparison; }  @Override int compare(String s1, String s2);  }
@Test public void should_compare_asc() { assertEquals(-1, comparator.compare("1", "2")); }
@Test public void should_compare_desc_with_two_chars() { assertEquals(1, comparator.compare("13", "6")); }
@Test public void should_compare_equal() { assertEquals(0, comparator.compare("1", "1")); }
@Test public void should_compare_numeric_with_text() { assertEquals(0, comparator.compare("1", "text")); }