# PackageItemInfo.DisplayNameComparator

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

# DisplayNameComparator

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/android/content/pm/PackageItemInfo.DisplayNameComparator "View this page in Java")  

```
open class DisplayNameComparator : Comparator<PackageItemInfo!>
```

|---|----------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                                                                                       ||
| ↳ | [android.content.pm.PackageItemInfo.DisplayNameComparator](https://developer.android.com/reference/kotlin/android/content/pm/PackageItemInfo.DisplayNameComparator#) |

## Summary

|                                                                                                                                                Public constructors                                                                                                                                                 ||
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [DisplayNameComparator](https://developer.android.com/reference/kotlin/android/content/pm/PackageItemInfo.DisplayNameComparator#DisplayNameComparator(android.content.pm.PackageManager))`(`pm:` `[PackageManager](https://developer.android.com/reference/kotlin/android/content/pm/PackageManager)!`)` <br /> |

|                                                                                                                                                                                                                                                     Public methods                                                                                                                                                                                                                                                      ||
|----------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [compare](https://developer.android.com/reference/kotlin/android/content/pm/PackageItemInfo.DisplayNameComparator#compare(android.content.pm.PackageItemInfo,%20android.content.pm.PackageItemInfo))`(`aa:` `[PackageItemInfo](https://developer.android.com/reference/kotlin/android/content/pm/PackageItemInfo)!`, `ab:` `[PackageItemInfo](https://developer.android.com/reference/kotlin/android/content/pm/PackageItemInfo)!`)` <br /> |

| Inherited functions ||
|---|---|
| From class[Comparator](https://developer.android.com/reference/kotlin/java/util/Comparator.html#) |---------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [Comparator](https://developer.android.com/reference/kotlin/java/util/Comparator.html#)<T>! | [reversed](https://developer.android.com/reference/kotlin/java/util/Comparator.html#reversed())`()` <br /> Returns a comparator that imposes the reverse ordering of this comparator. <br />                                                                                                                                                                                                                                                                                                                                                                  | | [Comparator](https://developer.android.com/reference/kotlin/java/util/Comparator.html#)<T>! | [thenComparing](https://developer.android.com/reference/kotlin/java/util/Comparator.html#thenComparing(java.util.Comparator))`(`other:` `[Comparator](https://developer.android.com/reference/kotlin/java/util/Comparator.html#)<in` `T>!`)` <br /> Returns a lexicographic-order comparator with another comparator. If this`Comparator`considers two elements equal, i.e.`compare(a, b) == 0`,`other`is used to determine the order. The returned comparator is serializable if the specified comparator is also serializable. <br />                       | | [Comparator](https://developer.android.com/reference/kotlin/java/util/Comparator.html#)<T>! | [thenComparing](https://developer.android.com/reference/kotlin/java/util/Comparator.html#thenComparing(java.util.function.Function))`(`keyExtractor:` `[Function](https://developer.android.com/reference/kotlin/java/util/function/Function.html#)<in` `T,` `out` `U>!`)` <br /> Returns a lexicographic-order comparator with a function that extracts a`Comparable`sort key. <br />                                                                                                                                                                        | | [Comparator](https://developer.android.com/reference/kotlin/java/util/Comparator.html#)<T>! | [thenComparing](https://developer.android.com/reference/kotlin/java/util/Comparator.html#thenComparing(java.util.function.Function,%20java.util.Comparator))`(`keyExtractor:` `[Function](https://developer.android.com/reference/kotlin/java/util/function/Function.html#)<in` `T,` `out` `U>!`, `keyComparator:` `[Comparator](https://developer.android.com/reference/kotlin/java/util/Comparator.html#)<in` `U>!`)` <br /> Returns a lexicographic-order comparator with a function that extracts a key to be compared with the given`Comparator`. <br /> | | [Comparator](https://developer.android.com/reference/kotlin/java/util/Comparator.html#)<T>! | [thenComparingDouble](https://developer.android.com/reference/kotlin/java/util/Comparator.html#thenComparingDouble(java.util.function.ToDoubleFunction))`(`keyExtractor:` `[ToDoubleFunction](https://developer.android.com/reference/kotlin/java/util/function/ToDoubleFunction.html#)<in` `T>!`)` <br /> Returns a lexicographic-order comparator with a function that extracts a`double`sort key. <br />                                                                                                                                                   | | [Comparator](https://developer.android.com/reference/kotlin/java/util/Comparator.html#)<T>! | [thenComparingInt](https://developer.android.com/reference/kotlin/java/util/Comparator.html#thenComparingInt(java.util.function.ToIntFunction))`(`keyExtractor:` `[ToIntFunction](https://developer.android.com/reference/kotlin/java/util/function/ToIntFunction.html#)<in` `T>!`)` <br /> Returns a lexicographic-order comparator with a function that extracts an`int`sort key. <br />                                                                                                                                                                    | | [Comparator](https://developer.android.com/reference/kotlin/java/util/Comparator.html#)<T>! | [thenComparingLong](https://developer.android.com/reference/kotlin/java/util/Comparator.html#thenComparingLong(java.util.function.ToLongFunction))`(`keyExtractor:` `[ToLongFunction](https://developer.android.com/reference/kotlin/java/util/function/ToLongFunction.html#)<in` `T>!`)` <br /> Returns a lexicographic-order comparator with a function that extracts a`long`sort key. <br />                                                                                                                                                               | ||

## Public constructors

### DisplayNameComparator

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
DisplayNameComparator(pm: PackageManager!)
```

## Public methods

### compare

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun compare(
    aa: PackageItemInfo!, 
    ab: PackageItemInfo!
): Int
```

|               Parameters                ||
|------|-----------------------------------|
| `o1` | the first object to be compared.  |
| `o2` | the second object to be compared. |

|                                                                                                Return                                                                                                 ||
|----------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------|
| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second. |

|                                                   Exceptions                                                   ||
|----------------------------------|------------------------------------------------------------------------------|
| `java.lang.NullPointerException` | if an argument is null and this comparator does not permit null arguments    |
| `java.lang.ClassCastException`   | if the arguments' types prevent them from being compared by this comparator. |