Skip to content

Instantly share code, notes, and snippets.

@markostam
Created November 11, 2016 19:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markostam/aa14d62611278dbbaeb25492d92b0bef to your computer and use it in GitHub Desktop.
Save markostam/aa14d62611278dbbaeb25492d92b0bef to your computer and use it in GitHub Desktop.
class QuickSort {
// quicksort function in scala
def sort(a:Array[Int]) : Array[Int] = {
if (a.length < 2) a
else {
val pivot = a(a.length/2)
sort(a.filter(_ < pivot)) ++ a.filter(_ == pivot) ++ sort(a.filter(_ > pivot))
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment