Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/scala/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
List Scala错误:值排序不是列表的成员_List_Scala_Sorting - Fatal编程技术网

List Scala错误:值排序不是列表的成员

List Scala错误:值排序不是列表的成员,list,scala,sorting,List,Scala,Sorting,下面是一个简单的例子: scala>val lst=List(1,7,2,8,5,6,3,9,14,12,4,10) 列表[Int]=列表(1,7,2,8,5,6,3,9,14,12,4,10) scala>lst.sort(>\uux) :9:错误:值排序不是列表[Int]的成员 一级排序(\u>\ u0) 怎么了? 谢谢 排序实际上没有在类中定义。您应该在本例中使用sortWith。SimplyScala很长时间没有更新:在2.8.0中,在以后的版本中被删除。相反,您必须使用sortWit

下面是一个简单的例子:

scala>val lst=List(1,7,2,8,5,6,3,9,14,12,4,10)
列表[Int]=列表(1,7,2,8,5,6,3,9,14,12,4,10)
scala>lst.sort(>\uux)
:9:错误:值排序不是列表[Int]的成员
一级排序(\u>\ u0)
怎么了?
谢谢

排序实际上没有在类中定义。您应该在本例中使用
sortWith

SimplyScala很长时间没有更新:在2.8.0中,在以后的版本中被删除。相反,您必须使用
sortWith
方法。

如果您正在运行新版本,如scala 2.11.8,您应该在此处检查文档。

搜索列表,您将获得三个排序选项:sortBy、sortWith和sorted。
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(_>_)