Sdílet prostřednictvím


Collator.Compare Method

Definition

Overloads

Compare(Object, Object)

Compares its two arguments for order.

Compare(String, String)

Compares the source string to the target string according to the collation rules for this Collator.

Compare(Object, Object)

Compares its two arguments for order.

[Android.Runtime.Register("compare", "(Ljava/lang/Object;Ljava/lang/Object;)I", "GetCompare_Ljava_lang_Object_Ljava_lang_Object_Handler")]
public virtual int Compare (Java.Lang.Object? o1, Java.Lang.Object? o2);
[<Android.Runtime.Register("compare", "(Ljava/lang/Object;Ljava/lang/Object;)I", "GetCompare_Ljava_lang_Object_Ljava_lang_Object_Handler")>]
abstract member Compare : Java.Lang.Object * Java.Lang.Object -> int
override this.Compare : Java.Lang.Object * Java.Lang.Object -> int

Parameters

o1
Object
o2
Object

Returns

a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

Attributes

Exceptions

if object1 or object2 is not a String.

Remarks

Compares its two arguments for order. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

This implementation merely returns compare((String)o1, (String)o2).

Added in 1.2.

Java documentation for java.text.Collator.compare(java.lang.Object, java.lang.Object).

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

Compare(String, String)

Compares the source string to the target string according to the collation rules for this Collator.

[Android.Runtime.Register("compare", "(Ljava/lang/String;Ljava/lang/String;)I", "GetCompare_Ljava_lang_String_Ljava_lang_String_Handler")]
public abstract int Compare (string? source, string? target);
[<Android.Runtime.Register("compare", "(Ljava/lang/String;Ljava/lang/String;)I", "GetCompare_Ljava_lang_String_Ljava_lang_String_Handler")>]
abstract member Compare : string * string -> int

Parameters

source
String

the source string.

target
String

the target string.

Returns

Returns an integer value. Value is less than zero if source is less than target, value is zero if source and target are equal, value is greater than zero if source is greater than target.

Attributes

Remarks

Compares the source string to the target string according to the collation rules for this Collator. Returns an integer less than, equal to or greater than zero depending on whether the source String is less than, equal to or greater than the target string. See the Collator class description for an example of use.

For a one time comparison, this method has the best performance. If a given String will be involved in multiple comparisons, CollationKey.compareTo has the best performance. See the Collator class description for an example using CollationKeys.

Java documentation for java.text.Collator.compare(java.lang.String, java.lang.String).

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