public int compare(Object o1, Object o2) {
      if (((String) o1).equals(o2)) return 0;

      History history = QualifiedTypeNameHistory.getDefault();

      int pos1 = history.getPosition(o1);
      int pos2 = history.getPosition(o2);

      if (pos1 == pos2) return Collator.getInstance().compare(o1, o2);

      if (pos1 > pos2) {
        return -1;
      } else {
        return 1;
      }
    }
  /*
   * @see org.eclipse.jdt.internal.ui.text.java.LazyJavaCompletionProposal#computeRelevance()
   */
  @Override
  protected int computeRelevance() {
    /*
     * There are two histories: the RHS history remembers types used for the current expected
     * type (left hand side), while the type history remembers recently used types in general).
     *
     * The presence of an RHS ranking is a much more precise sign for relevance as it proves the
     * subtype relationship between the proposed type and the expected type.
     *
     * The "recently used" factor (of either the RHS or general history) is less important, it should
     * not override other relevance factors such as if the type is already imported etc.
     */
    float rhsHistoryRank = fInvocationContext.getHistoryRelevance(getQualifiedTypeName());
    float typeHistoryRank =
        QualifiedTypeNameHistory.getDefault().getNormalizedPosition(getQualifiedTypeName());

    int recencyBoost = Math.round((rhsHistoryRank + typeHistoryRank) * 5);
    int rhsBoost = rhsHistoryRank > 0.0f ? 50 : 0;
    int baseRelevance = super.computeRelevance();

    return baseRelevance + rhsBoost + recencyBoost;
  }