getComparator

open fun getComparator(): Comparator<in T>?

If SORTED by a Comparator, returns that Comparator. If SORTED in natural order, returns null. Otherwise (not SORTED), throws IllegalStateException.

Default implementation always throws IllegalStateException.

Return

A Comparator, or null if sorted naturally.

Throws

if not SORTED.