Skip to content

Instantly share code, notes, and snippets.

@rbobillot
Last active October 28, 2016 21:58
Show Gist options
  • Save rbobillot/5cc132bcc734f92e50b4 to your computer and use it in GitHub Desktop.
Save rbobillot/5cc132bcc734f92e50b4 to your computer and use it in GitHub Desktop.
def qsort : Seq[Int] => Seq[Int] =
a => (a.size < 2) match {
case true => a
case false =>
val pivot = a(a.size / 2)
qsort (
a filter (pivot > _)) ++
(a filter (pivot == _)) ++
qsort (a filter (pivot < _)
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment