Freigeben über


IComparator.Comparing Method

Definition

Overloads

Comparing(IFunction)

Accepts a function that extracts a java.lang.Comparable Comparable sort key from a type T, and returns a Comparator<T> that compares by that sort key.

Comparing(IFunction, IComparator)

Accepts a function that extracts a sort key from a type T, and returns a Comparator<T> that compares by that sort key using the specified Comparator.

Comparing(IFunction)

Accepts a function that extracts a java.lang.Comparable Comparable sort key from a type T, and returns a Comparator<T> that compares by that sort key.

[Android.Runtime.Register("comparing", "(Ljava/util/function/Function;)Ljava/util/Comparator;", "", ApiSince=24)]
[Java.Interop.JavaTypeParameters(new System.String[] { "T", "U extends java.lang.Comparable<? super U>" })]
public static Java.Util.IComparator? Comparing (Java.Util.Functions.IFunction? keyExtractor);
[<Android.Runtime.Register("comparing", "(Ljava/util/function/Function;)Ljava/util/Comparator;", "", ApiSince=24)>]
[<Java.Interop.JavaTypeParameters(new System.String[] { "T", "U extends java.lang.Comparable<? super U>" })>]
static member Comparing : Java.Util.Functions.IFunction -> Java.Util.IComparator

Parameters

keyExtractor
IFunction

the function used to extract the Comparable sort key

Returns

a comparator that compares by an extracted key

Attributes

Remarks

Accepts a function that extracts a java.lang.Comparable Comparable sort key from a type T, and returns a Comparator<T> that compares by that sort key.

The returned comparator is serializable if the specified function is also serializable.

Added in 1.8.

Java documentation for java.util.Comparator.comparing(java.util.function.Function<? super T, ? extends U>).

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

Comparing(IFunction, IComparator)

Accepts a function that extracts a sort key from a type T, and returns a Comparator<T> that compares by that sort key using the specified Comparator.

[Android.Runtime.Register("comparing", "(Ljava/util/function/Function;Ljava/util/Comparator;)Ljava/util/Comparator;", "", ApiSince=24)]
[Java.Interop.JavaTypeParameters(new System.String[] { "T", "U" })]
public static Java.Util.IComparator? Comparing (Java.Util.Functions.IFunction? keyExtractor, Java.Util.IComparator? keyComparator);
[<Android.Runtime.Register("comparing", "(Ljava/util/function/Function;Ljava/util/Comparator;)Ljava/util/Comparator;", "", ApiSince=24)>]
[<Java.Interop.JavaTypeParameters(new System.String[] { "T", "U" })>]
static member Comparing : Java.Util.Functions.IFunction * Java.Util.IComparator -> Java.Util.IComparator

Parameters

keyExtractor
IFunction

the function used to extract the sort key

keyComparator
IComparator

the Comparator used to compare the sort key

Returns

a comparator that compares by an extracted key using the specified Comparator

Attributes

Remarks

Accepts a function that extracts a sort key from a type T, and returns a Comparator<T> that compares by that sort key using the specified Comparator.

The returned comparator is serializable if the specified function and comparator are both serializable.

Added in 1.8.

Java documentation for java.util.Comparator.comparing(java.util.function.Function<? super T, ? extends U>, java.util.Comparator<? super U>).

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