Realm v0.1.0 Realm.Ord protocol View Source

Ord describes how to order elements of a data type. This is a total order, so all elements are either :equal, :greater, or :lesser than each other.

Type Class

An instance of Realm.Ord must also implement Realm.Setoid, and define Realm.Ord.compare/2.

Setoid  [equivalent?/2]
  
 Ord    [compare/2]

Link to this section Summary

Functions

Get the ordering relationship between two elements. Possible results are :lesser, :equal, and :greater

Link to this section Types

Link to this type

ordering()

View Source
ordering() :: :lesser | :equal | :greater

Link to this section Functions

Link to this function

compare(left, right)

View Source
compare(t(), t()) :: ordering()

Get the ordering relationship between two elements. Possible results are :lesser, :equal, and :greater

Examples

iex> Realm.Ord.compare(1, 1)
:equal
iex> Realm.Ord.compare([1], [2])
:lesser
iex> Realm.Ord.compare([1, 2], [3])
:lesser
iex> Realm.Ord.compare([3, 2, 1], [1, 2, 3, 4, 5])
:greater