快速排序

def sort(xs: Array[Int]): Array[Int] =
  if (xs.length <= 1) xs
  else {
    val pivot = xs(xs.length / 2)
    Array.concat(
      sort(xs filter (pivot >)),
           xs filter (pivot ==),
      sort(xs filter (pivot <)))
  }

 

相关文章:

  • 2022-12-23
  • 2021-11-11
  • 2022-12-23
  • 2021-06-18
  • 2022-12-23
  • 2021-12-10
  • 2022-12-23
  • 2021-04-13
猜你喜欢
  • 2022-12-23
  • 2022-02-26
  • 2021-12-06
  • 2021-04-28
  • 2022-12-23
  • 2022-12-23
  • 2021-06-08
相关资源
相似解决方案