Skip to content

Instantly share code, notes, and snippets.

@Puriney
Created July 26, 2013 03:19
Show Gist options
  • Save Puriney/6085877 to your computer and use it in GitHub Desktop.
Save Puriney/6085877 to your computer and use it in GitHub Desktop.
R: Quick Sort
qsort <- function(v) {
if ( length(v) > 1 )
{
pivot <- median(v) # median value as pivot value
c(qsort(v[v < pivot]), v[v == pivot], qsort(v[v > pivot]))
} else v
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment