Scala error: value sort not on the list

Following a simple example at http://www.simplyscala.com/ , I get:

scala> val lst=List(1,7,2,8,5,6,3,9,14,12,4,10) lst: List[Int] = List(1, 7, 2, 8, 5, 6, 3, 9, 14, 12, 4, 10) scala> lst.sort(_>_) <console>:9: error: value sort is not a member of List[Int] lst.sort(_>_) 

What's wrong? Thanks!

+7
source share
3 answers

SimplyScala has not been updated for a long time:. Sort is deprecated in 2.8.0 and cut in recent versions. Instead, you should use the sortWith method.

+15
source

sort is not actually defined in the List class. You should use sortWith in your case.

+2
source

If you are using a newer version, for example scala 2.11.8, you should check the scala 2.11.8 lib API document here.

0
source

All Articles