Skip to content

Instantly share code, notes, and snippets.

@kaandedeoglu
Last active August 29, 2015 14:02
Show Gist options
  • Save kaandedeoglu/36123230d9524721cc60 to your computer and use it in GitHub Desktop.
Save kaandedeoglu/36123230d9524721cc60 to your computer and use it in GitHub Desktop.
QuickSort
func qckSort<T: Comparable>(v: T[]) -> T[] {
switch v {
case []:
return []
default:
let head = v[0]
var tail = v.copy()
tail.removeAtIndex(0)
return qckSort(tail.filter({$0 <= head})) + [head] + qckSort(tail.filter({$0 > head}))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment