package algorithm  QuickSortApp {  def QuickSort(list: List[Int]): List[Int] = {    list match {      case Nil => Nil      case List() => List()      case head :: tail =>                      // 使用head 作为算法中的基数        val (left, right) = tail.partition(_ < head)        QuickSort(left) ::: head :: QuickSort(right)          // 递归调用,直到完成排序    }  }  def main(args: Array[String]): Unit = {    val lists: List[Int] = List(1, 10, 8, 100, -234, 0, 100)    for (ele <- lists) {      print(ele + "	")    }    val list2 = QuickSort(lists)    println()    for (ele <- list2) {      print(ele + "	")    }  }}
收藏 打印