## org.junit.runner.manipulation
Class Sorter

    java.lang.Object
      org.junit.runner.manipulation.Ordering
          org.junit.runner.manipulation.Sorter

All Implemented Interfaces:
  Comparator<Description>

Direct Known Subclasses:
  Alphanumeric

    public class Sorter

extends Ordering
implements Comparator<Description>

A `Sorter` orders tests. In general you will not need to use a `Sorter` directly. Instead, use `Request.sortWith(Comparator)`.

Since:
  4.0

Nested Class Summary

Nested classes/interfaces inherited from class org.junit.runner.manipulation.Ordering
`Ordering.Context, Ordering.Factory`

Field Summary
`static Sorter` `NULL` NULL is a `Sorter` that leaves elements in an undefined order

Constructor Summary
`Sorter(Comparator<Description> comparator)` Creates a `Sorter` that uses `comparator` to sort tests

Method Summary
`void` `apply(Object target)` Sorts the tests in `target` using `comparator`.
`int` `compare(Description o1, Description o2)`
`protected List<Description>` `orderItems(Collection<Description> descriptions)` Implemented by sub-classes to order the descriptions.

Methods inherited from class org.junit.runner.manipulation.Ordering
`definedBy, definedBy, shuffledBy`

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`

Field Detail

### NULL

    public static final Sorter NULL

  NULL is a `Sorter` that leaves elements in an undefined order

Constructor Detail

### Sorter

    public Sorter(Comparator<Description> comparator)

  Creates a `Sorter` that uses `comparator` to sort tests

  Parameters:
    `comparator` - the `Comparator` to use when sorting tests
  Since:
    4.0

Method Detail

### apply

    public void apply(Object target)

  Sorts the tests in `target` using `comparator`.

  Overrides:
    `apply` in class `Ordering`
  Since:
    4.0

### compare

    public int compare(Description o1,
                       Description o2)

  Specified by:
    `compare` in interface `Comparator<Description>`

### orderItems

    protected final List<Description> orderItems(Collection<Description> descriptions)

  Implemented by sub-classes to order the descriptions.

  Specified by:
    `orderItems` in class `Ordering`
  Returns:
    descriptions in order
  Since:
    4.13

Copyright © 2002–2020 JUnit. All rights reserved.