diff options
author | Paul Phillips <paulp@improving.org> | 2009-10-22 21:58:29 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2009-10-22 21:58:29 +0000 |
commit | dab03ce57930c24534e46664b676eab1928ca34a (patch) | |
tree | 0c6a0f3d22d821f868b8ccf82fe61c574297c26c | |
parent | 99dae57ebb9204a8c99d063fa0666247134d109d (diff) | |
download | scala-dab03ce57930c24534e46664b676eab1928ca34a.tar.gz scala-dab03ce57930c24534e46664b676eab1928ca34a.tar.bz2 scala-dab03ce57930c24534e46664b676eab1928ca34a.zip |
Made sortBy unexperimental.
-rw-r--r-- | src/library/scala/Ordering.scala | 4 | ||||
-rw-r--r-- | src/library/scala/collection/SeqLike.scala | 12 |
2 files changed, 7 insertions, 9 deletions
diff --git a/src/library/scala/Ordering.scala b/src/library/scala/Ordering.scala index 4a90a03dfb..223d0bf37d 100644 --- a/src/library/scala/Ordering.scala +++ b/src/library/scala/Ordering.scala @@ -92,8 +92,8 @@ trait Ordering[T] extends Comparator[T] with PartialOrdering[T] { def compare(x: T, y: T) = outer.compare(y, x) } - /** Given a function mapping U => T, creates Ordering[U]. */ - def map[U](f: U => T): Ordering[U] = new Ordering[U] { + /** Given a function U => T, creates Ordering[U]. */ + def on[U](f: U => T): Ordering[U] = new Ordering[U] { def compare(x: U, y: U) = outer.compare(f(x), f(y)) } diff --git a/src/library/scala/collection/SeqLike.scala b/src/library/scala/collection/SeqLike.scala index a551a0b961..14227d4602 100644 --- a/src/library/scala/collection/SeqLike.scala +++ b/src/library/scala/collection/SeqLike.scala @@ -562,23 +562,21 @@ trait SeqLike[+A, +Repr] extends IterableLike[A, Repr] { self => b.result } - /** Sort the sequence according to the Ordering which results from mapping + /** Sort the sequence according to the Ordering which results from transforming * the implicitly given Ordering[B] to an Ordering[A]. For example: * * <code> * val words = "The quick brown fox jumped over the lazy dog".split(' ') * // this works because scala.Ordering will implicitly provide an Ordering[Tuple2[Int, Char]] - * words.sortBy(x => (x.length, x.head.toLower)) - * res0: Array[String] = Array(dog, fox, The, the, lazy, over, brown, quick, jumped) + * words.sortBy(x => (x.length, x.head)) + * res0: Array[String] = Array(The, dog, fox, the, lazy, over, brown, quick, jumped) * </code> * - * @param f the mapping function + * @param f the transformation function A => B * @param ord the Ordering[B] * @return the sorted representation */ - - @experimental - def sortBy[B](f: A => B)(implicit ord: Ordering[B]): Repr = sortWith(ord map f) + def sortBy[B](f: A => B)(implicit ord: Ordering[B]): Repr = sortWith(ord on f) /** * Overridden for efficiency. |