Package org.eclipse.jdt.ui.text.java

# Class CompletionProposalComparator

java.lang.Object
org.eclipse.jdt.ui.text.java.CompletionProposalComparator

All Implemented Interfaces:
  `Comparator<ICompletionProposal>`

public final class CompletionProposalComparator extends Object implements Comparator<ICompletionProposal>
Comparator for java completion proposals. Completion proposals can be sorted by relevance or alphabetically.

Note: this comparator imposes orderings that are inconsistent with equals.

Since:
  3.1

## Constructor Summary

Constructors
Constructor
Description
`CompletionProposalComparator()`
Creates a comparator that sorts by relevance.

## Method Summary

Modifier and Type
Method
Description
`int`
`compare(ICompletionProposal p1, ICompletionProposal p2)`
`void`
`setOrderAlphabetically(boolean orderAlphabetically)`
Sets the sort order.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface java.util.Comparator

`equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong`

## Constructor Details

### CompletionProposalComparator

public CompletionProposalComparator()
Creates a comparator that sorts by relevance.

## Method Details

### setOrderAlphabetically

public void setOrderAlphabetically(boolean orderAlphabetically)
Sets the sort order. Default is `false`, i.e. order by relevance.

Parameters:
  `orderAlphabetically` - `true` to order alphabetically, `false` to order by relevance

### compare

public int compare(ICompletionProposal p1, ICompletionProposal p2)

Specified by:
  `compare` in interface `Comparator<ICompletionProposal>`
Since:
  3.7