Aracılığıyla paylaş


Collections.ReverseOrder Method

Definition

Overloads

ReverseOrder(IComparator)

Returns a comparator that imposes the reverse ordering of the specified comparator.

ReverseOrder()

Returns a comparator that imposes the reverse of the <em>natural ordering</em> on a collection of objects that implement the Comparable interface.

ReverseOrder(IComparator)

Returns a comparator that imposes the reverse ordering of the specified comparator.

[Android.Runtime.Register("reverseOrder", "(Ljava/util/Comparator;)Ljava/util/Comparator;", "")]
[Java.Interop.JavaTypeParameters(new System.String[] { "T" })]
public static Java.Util.IComparator ReverseOrder (Java.Util.IComparator? cmp);
[<Android.Runtime.Register("reverseOrder", "(Ljava/util/Comparator;)Ljava/util/Comparator;", "")>]
[<Java.Interop.JavaTypeParameters(new System.String[] { "T" })>]
static member ReverseOrder : Java.Util.IComparator -> Java.Util.IComparator

Parameters

cmp
IComparator

a comparator who's ordering is to be reversed by the returned comparator or null

Returns

A comparator that imposes the reverse ordering of the specified comparator.

Attributes

Remarks

Returns a comparator that imposes the reverse ordering of the specified comparator. If the specified comparator is null, this method is equivalent to #reverseOrder() (in other words, it returns a comparator that imposes the reverse of the <em>natural ordering</em> on a collection of objects that implement the Comparable interface).

The returned comparator is serializable (assuming the specified comparator is also serializable or null).

Added in 1.5.

Java documentation for java.util.Collections.reverseOrder(java.util.Comparator<T>).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

ReverseOrder()

Returns a comparator that imposes the reverse of the <em>natural ordering</em> on a collection of objects that implement the Comparable interface.

[Android.Runtime.Register("reverseOrder", "()Ljava/util/Comparator;", "")]
[Java.Interop.JavaTypeParameters(new System.String[] { "T" })]
public static Java.Util.IComparator ReverseOrder ();
[<Android.Runtime.Register("reverseOrder", "()Ljava/util/Comparator;", "")>]
[<Java.Interop.JavaTypeParameters(new System.String[] { "T" })>]
static member ReverseOrder : unit -> Java.Util.IComparator

Returns

A comparator that imposes the reverse of the natural ordering on a collection of objects that implement the Comparable interface.

Attributes

Remarks

Returns a comparator that imposes the reverse of the <em>natural ordering</em> on a collection of objects that implement the Comparable interface. (The natural ordering is the ordering imposed by the objects' own compareTo method.) This enables a simple idiom for sorting (or maintaining) collections (or arrays) of objects that implement the Comparable interface in reverse-natural-order. For example, suppose a is an array of strings. Then:

Arrays.sort(a, Collections.reverseOrder());

sorts the array in reverse-lexicographic (alphabetical) order.

The returned comparator is serializable.

Java documentation for java.util.Collections.reverseOrder().

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to