code: public List getSortedEntries() {
  
          Map grouped = new HashMap();
  
          for (int i = 0; i < indexentry.size(); i++) {
              Entry e = (Entry) indexentry.get(i);
              String key = e.getKey();
  
              Entry master = (Entry) grouped.get(key);
              if (master != null) {
                  master.addPageNumberAndTag(e.getPageNumber(), e.getTag());
              } else {
                  e.addPageNumberAndTag(e.getPageNumber(), e.getTag());
                  grouped.put(key, e);
              }
          }
  
          // copy to a list and sort it
          List sorted = new ArrayList(grouped.values());
          Collections.sort(sorted, comparator);
          return sorted;
      }
docs: Returns the sorted list with the entries and the collected page numbers.
  @return Returns the sorted list with the entries and the collected page numbers.