Skip to content

Commit 78ba5dc

Browse files
committed
Improve doc of Seq.sortWith
1 parent a6b4252 commit 78ba5dc

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

library/src/scala/collection/Seq.scala

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -735,22 +735,23 @@ trait SeqOps[+A, +CC[_], +C] extends Any
735735
}
736736

737737
/** Sorts this $coll according to a comparison function.
738-
* $willNotTerminateInf
739-
* $willForceEvaluation
740-
*
741-
* The sort is stable. That is, elements that are equal (as determined by
742-
* `lt`) appear in the same order in the sorted sequence as in the original.
743-
*
744-
* @param lt the comparison function which tests whether
745-
* its first argument precedes its second argument in
746-
* the desired ordering.
747-
* @return a $coll consisting of the elements of this $coll
748-
* sorted according to the comparison function `lt`.
749-
* @example {{{
750-
* List("Steve", "Tom", "John", "Bob").sortWith(_.compareTo(_) < 0) =
751-
* List("Bob", "John", "Steve", "Tom")
752-
* }}}
753-
*/
738+
* $willNotTerminateInf
739+
* $willForceEvaluation
740+
*
741+
* The sort is stable. That is, elements that are equal
742+
* (`lt` returns false for both directions of comparison)
743+
* appear in the same order in the sorted sequence as in the original.
744+
*
745+
* @param lt a predicate that is true if
746+
* its first argument strictly precedes its second argument in
747+
* the desired ordering.
748+
* @return a $coll consisting of the elements of this $coll
749+
* sorted according to the comparison function `lt`.
750+
* @example {{{
751+
* List("Steve", "Bobby", "Tom", "John", "Bob").sortWith((x, y) => x.take(3).compareTo(y.take(3)) < 0) =
752+
* List("Bobby", "Bob", "John", "Steve", "Tom")
753+
* }}}
754+
*/
754755
def sortWith(lt: (A, A) => Boolean): C = sorted(Ordering.fromLessThan(lt))
755756

756757
/** Sorts this $coll according to the Ordering which results from transforming

0 commit comments

Comments
 (0)