Object

scala.util

Sorting

Related Doc: package util

Permalink

object Sorting

The Sorting object provides convenience wrappers for java.util.Arrays.sort. Methods that defer to java.util.Arrays.sort say that they do or under what conditions that they do.

Sorting also implements a general-purpose quicksort and stable (merge) sort for those cases where java.util.Arrays.sort could only be used at the cost of a large memory penalty. If performance rather than memory usage is the primary concern, one may wish to find alternate strategies to use java.util.Arrays.sort directly e.g. by boxing primitives to use a custom ordering on them.

Sorting provides methods where you can provide a comparison function, or can request a sort of items that are scala.math.Ordered or that otherwise have an implicit or explicit scala.math.Ordering.

Note also that high-performance non-default sorts for numeric types are not provided. If this is required, it is advisable to investigate other libraries that cover this use case.

Version

1.1

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Sorting
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  5. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  6. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  7. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  8. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  9. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  10. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  11. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  12. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  13. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  14. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  15. def quickSort[K](a: Array[K])(implicit arg0: math.Ordering[K]): Unit

    Permalink

    Sort array a with quicksort, using the Ordering on its elements.

    Sort array a with quicksort, using the Ordering on its elements. This algorithm sorts in place, so no additional memory is used aside from what might be required to box individual elements during comparison.

  16. def quickSort(a: Array[Float]): Unit

    Permalink

    Sort an array of Floats using java.util.Arrays.sort.

  17. def quickSort(a: Array[Int]): Unit

    Permalink

    Sort an array of Ints using java.util.Arrays.sort.

  18. def quickSort(a: Array[Double]): Unit

    Permalink

    Sort an array of Doubles using java.util.Arrays.sort.

  19. def stableSort[K, M](a: Seq[K], f: (K) ⇒ M)(implicit arg0: ClassTag[K], arg1: math.Ordering[M]): Array[K]

    Permalink

    A sorted Array, given an extraction function f that returns an ordered key for each item in the sequence a.

    A sorted Array, given an extraction function f that returns an ordered key for each item in the sequence a. Uses java.util.Arrays.sort unless K is a primitive type.

  20. def stableSort[K](a: Seq[K], f: (K, K) ⇒ Boolean)(implicit arg0: ClassTag[K]): Array[K]

    Permalink

    A sorted Array, given a function f that computes the less-than relation for each item in the sequence a.

    A sorted Array, given a function f that computes the less-than relation for each item in the sequence a. Uses java.util.Arrays.sort unless K is a primitive type.

  21. def stableSort[K](a: Seq[K])(implicit arg0: ClassTag[K], arg1: math.Ordering[K]): Array[K]

    Permalink

    A sorted Array, using the Ordering for the elements in the sequence a.

    A sorted Array, using the Ordering for the elements in the sequence a. Uses java.util.Arrays.sort unless K is a primitive type.

  22. def stableSort[K](a: Array[K], f: (K, K) ⇒ Boolean)(implicit arg0: ClassTag[K]): Unit

    Permalink

    Sort array a using function f that computes the less-than relation for each element.

    Sort array a using function f that computes the less-than relation for each element. Uses java.util.Arrays.sort unless K is a primitive type.

  23. def stableSort[K](a: Array[K])(implicit arg0: ClassTag[K], arg1: math.Ordering[K]): Unit

    Permalink

    Sort array a using the Ordering on its elements, preserving the original ordering where possible.

    Sort array a using the Ordering on its elements, preserving the original ordering where possible. Uses java.util.Arrays.sort unless K is a primitive type.

  24. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  25. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  26. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  27. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  28. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from AnyRef

Inherited from Any

Ungrouped