Created
November 11, 2016 19:58
-
-
Save markostam/aa14d62611278dbbaeb25492d92b0bef to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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