source: class SortUtilsTest {
  
      @Test
      public void testFragmentSortA() throws Exception {
  
target:         List<String> fragmentList = new ArrayList<String>();
          for (int i = 0; i < 6; i++) {
              fragmentList.add(String.valueOf((char) ('A' + i)));
          }
          List<String> sortedList = SortUtils.sort(fragmentList, new Visitor<String>() {
  
              @Override
              public boolean afterOthers(String t) {
                  if (t.equals("A") || t.equals("C")) {
                      return true;
                  }
                  return false;
              }
  
              @Override
              public boolean beforeOthers(String t) {
                  if (t.equals("B") || t.equals("F")) {
                      return true;
                  }
                  return false;
              }
  
              @Override
              public List<String> getAfterNames(String t) {
                  if (t.equals("A")) {
                      return Arrays.asList("C");
                  }
                  return Collections.emptyList();
              }
  
              @Override
              public List<String> getBeforeNames(String t) {
                  if (t.equals("F")) {
                      return Arrays.asList("B");
                  }
                  return Collections.emptyList();
              }
  
              @Override
              public String getName(String t) {
                  return t;
              }
  
          });
          Assert.assertEquals(Arrays.asList("F", "B", "D", "E", "C", "A"), sortedList);
      }
  
  }