Ordering

type Ordering[A] = scala.math.Ordering[A]

Scalqa Ordering is an alias to scala.Ordering. Both can be used interchangeably.

Scalqa Ordering has a new set of methods provided as extensions.

Source
Ordering.scala

Def

@targetName("join")
inline def +[A](c: Ordering[A]): Ordering[A]

Alias for join

Alias for join

Creates a new Ordering, which will order elements based on this Ordering, and if they appear equal, on joined Ordering

Source
Ordering.scala
inline def compare[A](v: A, w: A): Int

Compare elements

Compare elements

This is the only abstract method to be implemented.

Returns Int value < 0 (usually -1), if first element is less than second.

Returns Int value > 0 (usually 1), if first element is greater than second.

Returns Int value of 0, if two elements are equal.

Source
Ordering.scala
inline def compareOpt[A](v: Opt[A], w: Opt[A], none: Int): Int
inline def join[A](c: Ordering[A]): Ordering[A]

Join

Join

Creates a new Ordering, which will order elements based on this Ordering, and if they appear equal, on joined Ordering

Source
Ordering.scala
inline def map[A](f: U => A): Ordering[U]

Map to type

Map to type

Maps current ordering to specified type.

Note. Mapping function takes target type value and has to convert it to current type.

 val stringOrdering = Ordering[String]

 val intOrdering = stringOrdering.map[Int](i => i.toString)
Source
Ordering.scala
inline def reverse[A]: Ordering[A]

Reversed ordering

Reversed ordering

Returns ordering with reversed order

Source
Ordering.scala