This is the companion object for the scala.math.Ordering trait.
It contains many implicit orderings as well as well as methods to construct new orderings.
Attributes
- Companion
- trait
- Source
- Ordering.scala
- Graph
-
- Supertypes
- Self type
-
Ordering.type
Members list
Type members
Classlikes
Attributes
- Source
- Ordering.scala
- Supertypes
-
trait BigDecimalOrderingtrait Ordering[BigDecimal]trait PartialOrdering[BigDecimal]trait Equiv[BigDecimal]trait Serializabletrait Comparator[BigDecimal]class Objecttrait Matchableclass AnyShow all
- Self type
-
BigDecimal.type
Attributes
- Source
- Ordering.scala
- Supertypes
-
trait Ordering[BigDecimal]trait PartialOrdering[BigDecimal]trait Equiv[BigDecimal]trait Serializabletrait Comparator[BigDecimal]class Objecttrait Matchableclass AnyShow all
- Known subtypes
Attributes
- Source
- Ordering.scala
- Supertypes
-
trait BigIntOrderingtrait PartialOrdering[BigInt]trait Serializabletrait Comparator[BigInt]class Objecttrait Matchableclass AnyShow all
- Self type
-
BigInt.type
Attributes
- Source
- Ordering.scala
- Supertypes
-
trait PartialOrdering[BigInt]trait Serializabletrait Comparator[BigInt]class Objecttrait Matchableclass AnyShow all
- Known subtypes
-
object BigIntIsIntegral.typeobject BigInt.type
Attributes
- Source
- Ordering.scala
- Supertypes
-
trait BooleanOrderingtrait PartialOrdering[Boolean]trait Serializabletrait Comparator[Boolean]class Objecttrait Matchableclass AnyShow all
- Self type
-
Boolean.type
Attributes
- Source
- Ordering.scala
- Supertypes
-
trait PartialOrdering[Boolean]trait Serializabletrait Comparator[Boolean]class Objecttrait Matchableclass AnyShow all
- Known subtypes
-
object Boolean.type
Attributes
- Source
- Ordering.scala
- Supertypes
-
trait ByteOrderingtrait PartialOrdering[Byte]trait Serializabletrait Comparator[Byte]class Objecttrait Matchableclass AnyShow all
- Self type
-
Byte.type
Attributes
- Source
- Ordering.scala
- Supertypes
-
trait PartialOrdering[Byte]trait Serializabletrait Comparator[Byte]class Objecttrait Matchableclass AnyShow all
- Known subtypes
-
object ByteIsIntegral.typeobject Byte.type
An ordering which caches the value of its reverse.
An ordering which caches the value of its reverse.
Attributes
- Source
- Ordering.scala
- Supertypes
-
trait Ordering[T]trait PartialOrdering[T]trait Equiv[T]trait Serializabletrait Comparator[T]class Objecttrait Matchableclass AnyShow all
- Known subtypes
-
object Int.type
Attributes
- Source
- Ordering.scala
- Supertypes
-
trait CharOrderingtrait PartialOrdering[Char]trait Serializabletrait Comparator[Char]class Objecttrait Matchableclass AnyShow all
- Self type
-
Char.type
Attributes
- Source
- Ordering.scala
- Supertypes
-
trait PartialOrdering[Char]trait Serializabletrait Comparator[Char]class Objecttrait Matchableclass AnyShow all
- Known subtypes
-
object CharIsIntegral.typeobject Char.type
Attributes
- Source
- Ordering.scala
- Supertypes
-
trait TotalOrderingtrait PartialOrdering[Double]trait Serializabletrait Comparator[Double]class Objecttrait Matchableclass AnyShow all
- Self type
Attributes
- Source
- Ordering.scala
- Supertypes
-
trait TotalOrderingtrait PartialOrdering[Float]trait Serializabletrait Comparator[Float]class Objecttrait Matchableclass AnyShow all
- Self type
Ordering
s for Double
s.
Ordering
s for Double
s.
The behavior of the comparison operations provided by the default (implicit) ordering on Double
changed in 2.10.0 and 2.13.0. Prior to Scala 2.10.0, the Ordering
instance used semantics consistent with java.lang.Double.compare
.
Scala 2.10.0 changed the implementation of lt
, equiv
, min
, etc., to be IEEE 754 compliant, while keeping the compare
method NOT compliant, creating an internally inconsistent instance. IEEE 754 specifies that 0.0 == -0.0
. In addition, it requires all comparisons with Double.NaN
return false
thus 0.0 < Double.NaN
, 0.0 > Double.NaN
, and Double.NaN == Double.NaN
all yield false
, analogous None
in flatMap
.
Recognizing the limitation of the IEEE 754 semantics in terms of ordering, Scala 2.13.0 created two instances: Ordering.Double.IeeeOrdering
, which retains the IEEE 754 semantics from Scala 2.12.x, and Ordering.Double.TotalOrdering
, which brings back the java.lang.Double.compare
semantics for all operations. The default extends TotalOrdering
.
List(0.0, 1.0, 0.0 / 0.0, -1.0 / 0.0).sorted // List(-Infinity, 0.0, 1.0, NaN)
List(0.0, 1.0, 0.0 / 0.0, -1.0 / 0.0).min // -Infinity
implicitly[Ordering[Double]].lt(0.0, 0.0 / 0.0) // true
{
import Ordering.Double.IeeeOrdering
List(0.0, 1.0, 0.0 / 0.0, -1.0 / 0.0).sorted // List(-Infinity, 0.0, 1.0, NaN)
List(0.0, 1.0, 0.0 / 0.0, -1.0 / 0.0).min // NaN
implicitly[Ordering[Double]].lt(0.0, 0.0 / 0.0) // false
}
Attributes
- Source
- Ordering.scala
- Supertypes
- Self type
-
Double.type
Attributes
- Source
- Ordering.scala
- Supertypes
- Known subtypes
-
object Implicits.type
Ordering
s for Float
s.
Ordering
s for Float
s.
The behavior of the comparison operations provided by the default (implicit) ordering on Float
changed in 2.10.0 and 2.13.0. Prior to Scala 2.10.0, the Ordering
instance used semantics consistent with java.lang.Float.compare
.
Scala 2.10.0 changed the implementation of lt
, equiv
, min
, etc., to be IEEE 754 compliant, while keeping the compare
method NOT compliant, creating an internally inconsistent instance. IEEE 754 specifies that 0.0F == -0.0F
. In addition, it requires all comparisons with Float.NaN
return false
thus 0.0F < Float.NaN
, 0.0F > Float.NaN
, and Float.NaN == Float.NaN
all yield false
, analogous None
in flatMap
.
Recognizing the limitation of the IEEE 754 semantics in terms of ordering, Scala 2.13.0 created two instances: Ordering.Float.IeeeOrdering
, which retains the IEEE 754 semantics from Scala 2.12.x, and Ordering.Float.TotalOrdering
, which brings back the java.lang.Float.compare
semantics for all operations. The default extends TotalOrdering
.
List(0.0F, 1.0F, 0.0F / 0.0F, -1.0F / 0.0F).sorted // List(-Infinity, 0.0, 1.0, NaN)
List(0.0F, 1.0F, 0.0F / 0.0F, -1.0F / 0.0F).min // -Infinity
implicitly[Ordering[Float]].lt(0.0F, 0.0F / 0.0F) // true
{
import Ordering.Float.IeeeOrdering
List(0.0F, 1.0F, 0.0F / 0.0F, -1.0F / 0.0F).sorted // List(-Infinity, 0.0, 1.0, NaN)
List(0.0F, 1.0F, 0.0F / 0.0F, -1.0F / 0.0F).min // NaN
implicitly[Ordering[Float]].lt(0.0F, 0.0F / 0.0F) // false
}
Attributes
- Source
- Ordering.scala
- Supertypes
- Self type
-
Float.type
An object containing implicits which are not in the default scope.
An object containing implicits which are not in the default scope.
Attributes
- Source
- Ordering.scala
- Supertypes
- Self type
-
Implicits.type
Attributes
- Source
- Ordering.scala
- Supertypes
-
trait CachedReverse[Int]trait IntOrderingtrait PartialOrdering[Int]trait Serializabletrait Comparator[Int]class Objecttrait Matchableclass AnyShow all
- Self type
-
Int.type
Attributes
- Source
- Ordering.scala
- Supertypes
-
trait PartialOrdering[Int]trait Serializabletrait Comparator[Int]class Objecttrait Matchableclass AnyShow all
- Known subtypes
-
object IntIsIntegral.typeobject Int.type
Attributes
- Source
- Ordering.scala
- Supertypes
-
trait LongOrderingtrait PartialOrdering[Long]trait Serializabletrait Comparator[Long]class Objecttrait Matchableclass AnyShow all
- Self type
-
Long.type
Attributes
- Source
- Ordering.scala
- Supertypes
-
trait PartialOrdering[Long]trait Serializabletrait Comparator[Long]class Objecttrait Matchableclass AnyShow all
- Known subtypes
-
object LongIsIntegral.typeobject Long.type
Attributes
- Source
- Ordering.scala
- Supertypes
Attributes
- Source
- Ordering.scala
- Supertypes
-
trait ShortOrderingtrait PartialOrdering[Short]trait Serializabletrait Comparator[Short]class Objecttrait Matchableclass AnyShow all
- Self type
-
Short.type
Attributes
- Source
- Ordering.scala
- Supertypes
-
trait PartialOrdering[Short]trait Serializabletrait Comparator[Short]class Objecttrait Matchableclass AnyShow all
- Known subtypes
-
object ShortIsIntegral.typeobject Short.type
Attributes
- Source
- Ordering.scala
- Supertypes
-
trait StringOrderingtrait PartialOrdering[String]trait Serializabletrait Comparator[String]class Objecttrait Matchableclass AnyShow all
- Self type
-
String.type
Attributes
- Source
- Ordering.scala
- Supertypes
-
trait PartialOrdering[String]trait Serializabletrait Comparator[String]class Objecttrait Matchableclass AnyShow all
- Known subtypes
-
object String.type
Attributes
- Source
- Ordering.scala
- Supertypes
-
trait SymbolOrderingtrait PartialOrdering[Symbol]trait Serializabletrait Comparator[Symbol]class Objecttrait Matchableclass AnyShow all
- Self type
-
Symbol.type
Attributes
- Source
- Ordering.scala
- Supertypes
-
trait PartialOrdering[Symbol]trait Serializabletrait Comparator[Symbol]class Objecttrait Matchableclass AnyShow all
- Known subtypes
-
object Symbol.type
Attributes
- Source
- Ordering.scala
- Supertypes
-
trait UnitOrderingtrait PartialOrdering[Unit]trait Serializabletrait Comparator[Unit]class Objecttrait Matchableclass AnyShow all
- Self type
-
Unit.type
Attributes
- Source
- Ordering.scala
- Supertypes
-
trait PartialOrdering[Unit]trait Serializabletrait Comparator[Unit]class Objecttrait Matchableclass AnyShow all
- Known subtypes
-
object Unit.type
Inherited types
Attributes
- Inherited from:
- LowPriorityOrderingImplicits
- Source
- Ordering.scala
Value members
Concrete methods
Attributes
- Source
- Ordering.scala
Given f, a function from T into S, creates an Ordering[T] whose compare function is equivalent to:
Given f, a function from T into S, creates an Ordering[T] whose compare function is equivalent to:
def compare(x:T, y:T) = Ordering[S].compare(f(x), f(y))
This function is an analogue to Ordering.on where the Ordering[S] parameter is passed implicitly.
Attributes
- Source
- Ordering.scala
Construct an Ordering[T] given a function lt
.
Implicits
Implicits
Attributes
- Source
- Ordering.scala
Attributes
- Source
- Ordering.scala
Attributes
- Source
- Ordering.scala
Attributes
- Source
- Ordering.scala
Attributes
- Source
- Ordering.scala
Attributes
- Source
- Ordering.scala
Attributes
- Source
- Ordering.scala
Attributes
- Source
- Ordering.scala
Attributes
- Source
- Ordering.scala
Deprecated implicits
Attributes
- Deprecated
-
[Since version 2.13.0]
Iterables are not guaranteed to have a consistent order, so the
Ordering
returned by this method may not be stable or meaningful. If you are using a type with a consistent order (such asSeq
), use itsOrdering
(found in the Implicits object) instead. - Source
- Ordering.scala
Inherited implicits
Attributes
- Inherited from:
- LowPriorityOrderingImplicits
- Source
- Ordering.scala
This would conflict with all the nice implicit Orderings available, but thanks to the magic of prioritized implicits via subclassing we can make Ordered[A] => Ordering[A]
only turn up if nothing else works.
This would conflict with all the nice implicit Orderings available, but thanks to the magic of prioritized implicits via subclassing we can make Ordered[A] => Ordering[A]
only turn up if nothing else works. Since Ordered[A]
extends Comparable[A]
anyway, we can throw in some Java interop too.
Attributes
- Inherited from:
- LowPriorityOrderingImplicits
- Source
- Ordering.scala