Skip to content

Instantly share code, notes, and snippets.

@litiblue
Created December 19, 2014 13:17
Show Gist options
  • Save litiblue/fca2650b042f2fc9bf11 to your computer and use it in GitHub Desktop.
Save litiblue/fca2650b042f2fc9bf11 to your computer and use it in GitHub Desktop.
val input = List("1 10", "5 5","7 7")
val t = input.map(n=>n.split(' ').toList)
val (a, b) = t.map{case List(a,b) => (a,b)}.unzip
def sort(ls: List[Int]): List[Int] = {
ls match {
case Nil => Nil
case pivot :: tail => {
val (less, greater) = tail.partition(_ < pivot)
sort(less) ::: pivot :: sort(greater)
}
}
}
print(b.map(_.toInt))
sort(a.map(_.toInt))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment