scala 2.8에서 List의 sort 메소드는 deprecated되었고, 뒤 버전부터 사라졌다.
defsort (lt: (A, A) ⇒ Boolean) : List[A]
defsortBy [B] (f: (A) ⇒ B)(implicit ord: Ordering[B]) : List[A]
Sorts this List according to the Ordering which results from transforming an implicitly given Ordering with a transformation function.
defsortWith (lt: (A, A) ⇒ Boolean) : List[A]
Sorts this list according to a comparison function.
defsorted [B >: A] (implicit ord: Ordering[B]) : List[A]
Sorts this list according to an Ordering.
http://www.scala-lang.org/api/current/#scala.collection.immutable.List에서도 확인할 수 있다. (현재 2.11.8)
scala> thrill.sort((s,t) => s.charAt(0).toLower < t.charAt(0).toLower)
<console>:14: error: value sort is not a member of List[String]
thrill.sort((s,t) => s.charAt(0).toLower < t.charAt(0).toLower)
^
scala> thrill.sortWith((s,t) => s.charAt(0).toLower < t.charAt(0).toLower)
res11: List[String] = List(aa, bb)
scala> thrill.sortWith(_.charAt(0).toLower < _.charAt(0).toLower)
res12: List[String] = List(aa, bb)
scala> thrill.sortBy(_.charAt(0))
res14: List[String] = List(aa, bb)
scala> thrill.sorted
res15: List[String] = List(aa, bb)
'scala' 카테고리의 다른 글
[scala] 싱글톤 객체, 독립 객체, 동반 클래스 (0) | 2016.03.24 |
---|---|
[scala] =과 함수 선언 (0) | 2016.03.23 |
[Scala] ImmutableList의 remove() (0) | 2016.03.22 |
scala + scalatra + gradle (0) | 2015.11.30 |
[scalatra] scalate 에러 - java.lang.NoSuchMethodError: scala.tools.nsc.Global$gen$.mkBlock (0) | 2015.11.30 |
Sort the list according to the comparison function
lt(e1: a, e2: a) => Boolean
, which should be true iffe1
precedese2
in the desired ordering. !!! todo: move sorting to IterableLikethe comparison function
a list sorted according to the comparison function
lt(e1: a, e2: a) => Boolean
.deprecated:
use
sortWith' instead