Order

interface Order<A> : Eq<A> (source)

A type class for total orders on values of type A.

compare returns a negative number, zero or a positive number when a is less than, equivalent to or greater than b. Equivalence (eqv) is defined as compare(a, b) == 0.

Laws (in addition to the Eq laws):

  • Reflexivity: lteqv(a, a)

  • Antisymmetry: lteqv(a, b) && lteqv(b, a) implies eqv(a, b)

  • Transitivity: lteqv(a, b) && lteqv(b, c) implies lteqv(a, c)

  • Totality: lteqv(a, b) || lteqv(b, a)

Int.order.max(1, 2)                                 // 2
Maybe.order(Int.order).lt(Maybe.None(), Maybe.Just(0)) // true

Inheritors

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
abstract fun compare(a: A, b: A): Int

Compares a with b: negative when a < b, zero when equivalent, positive when a > b.

Link copied to clipboard
open override fun eqv(a: A, b: A): Boolean

Returns true when a and b are equivalent.

Link copied to clipboard
open fun gt(a: A, b: A): Boolean

Returns true when a is strictly greater than b.

Link copied to clipboard
open fun gteqv(a: A, b: A): Boolean

Returns true when a is greater than or equivalent to b.

Link copied to clipboard
open fun lt(a: A, b: A): Boolean

Returns true when a is strictly less than b.

Link copied to clipboard
open fun lteqv(a: A, b: A): Boolean

Returns true when a is less than or equivalent to b.

Link copied to clipboard
open fun max(a: A, b: A): A

Returns the larger of a and b, preferring a on ties.

Link copied to clipboard
open fun min(a: A, b: A): A

Returns the smaller of a and b, preferring a on ties.

Link copied to clipboard
open fun neqv(a: A, b: A): Boolean

Returns true when a and b are not equivalent.

Link copied to clipboard

Returns a Comparator for use with the standard library (e.g. sortedWith).