scala 2.8에서 List의 sort 메소드는 deprecated되었고, 뒤 버전부터 사라졌다. 


  1. defsort (lt: (A, A) ⇒ Boolean) List[A]

    Sort the list according to the comparison function lt(e1: a, e2: a) => Boolean, which should be true iff e1 precedes e2 in the desired ordering. !!! todo: move sorting to IterableLike

    lt

    the comparison function

    returns

    a list sorted according to the comparison function lt(e1: a, e2: a) => Boolean.

      deprecated: 
    1. use sortWith' instead

  2. 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.

  3. defsortWith (lt: (A, A) ⇒ Boolean) List[A]

    Sorts this list according to a comparison function.

  4. 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)


Posted by '김용환'
,