# Types

## Order

</>

Represents the result of a single comparison to determine the precise ordering of two values.

``````pub type Order {
Lt
Eq
Gt
}``````

### Constructors

• ``Lt``

Less-than

• ``Eq``

Equal

• ``Gt``

Greater than

# Functions

## compare

</>
``pub fn compare(a: Order, with b: Order) -> Order``

Compares two `Order` values to one another, producing a new `Order`.

## Examples

``````> compare(Eq, with: Lt)
Gt
``````

## max

</>
``pub fn max(a: Order, b: Order) -> Order``

Returns the largest of two orders given that `Gt > Eq > Lt`.

## Examples

``````> max(Eq, Lt)
Eq
``````

## min

</>
``pub fn min(a: Order, b: Order) -> Order``

Returns the smallest of two orders given that `Gt > Eq > Lt`.

## Examples

``````> min(Eq, Lt)
Lt
``````

## negate

</>
``pub fn negate(order: Order) -> Order``

Inverts an order, so less-than becomes greater-than and greater-than becomes less-than.

## Examples

``````> negate(Lt)
Gt
``````
``````> negate(Eq)
Eq
``````
``````> negate(Lt)
Gt
``````

## reverse

</>
``pub fn reverse(orderer: fn(a, a) -> Order) -> fn(a, a) -> Order``

Inverts an ordering function, so less-than becomes greater-than and greater-than becomes less-than.

## Examples

``````> list.sort([1, 5, 4], by: reverse(int.compare))
[5, 4, 1]
``````

## to_int

</>
``pub fn to_int(order: Order) -> Int``

Produces a numeric representation of the order.

## Examples

``````> to_int(Lt)
-1
``````
``````> to_int(Eq)
0
``````
``````> to_int(Gt)
1
``````