summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/library/scala/Ordering.scala4
-rw-r--r--src/library/scala/collection/SeqLike.scala12
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.