public Collection getYAxis(String orderBy, String direction) {
    Comparator comp;

    if (orderBy != null && orderBy.equals(TOTAL_ORDER)) {
      // Compare by total
      comp =
          new Comparator() {

            public int compare(Object o1, Object o2) {
              Long o1Long = new Long(getYAxisUniqueTotal(o1));
              Long o2Long = new Long(getYAxisUniqueTotal(o2));
              return o1Long.compareTo(o2Long);
            }
          };

      // Only reverse total Comaparator, not field Comparator
      if (direction != null && direction.equals(DESC)) {
        comp = new ReverseComparator(comp);
      }

      // If totals are equal, delagate back to field comparator
      comp = new DelegatingComparator(comp, ComparatorSelector.getComparator(yAxisMapper));
    } else {
      comp = yAxisMapper.getComparator();
      if (direction != null && direction.equals(DESC)) {
        comp = new ReverseComparator(comp);
      }
    }

    return getYAxis(comp);
  }
  /**
   * Transform values in the collection from Strings to Objects, using {@link
   * com.atlassian.jira.issue.search.LuceneFieldSorter#getValueFromLuceneField(String)}
   *
   * @param values A Collection of Strings, obtained from the Lucene Index
   * @param mapper A statsMapper used to convert to objects
   * @return a collection of transformed objects, never null
   */
  private static Collection transformAndRemoveInvaid(Collection values, StatisticsMapper mapper) {
    Collection output = new ArrayList();
    for (final Object value1 : values) {
      String key = (String) value1;
      final Object value;
      if (key != null) {
        value = mapper.getValueFromLuceneField(key);
      } else {
        value = null;
      }

      // only valid values should be added to the map
      if (mapper.isValidValue(value)) {
        output.add(value);
      }
    }
    return output;
  }