Javascript: Quick Sort Implementation

Quick sort is a divide and conquer sorting algorithm. It creates two empty arrays to hold elements less than the pivot value and elements greater than the pivot value, and then recurively sort the sub arrays.
Here is an example of quick sort in Javascript

function quicksort(data) {
    if (data.length == 0) return [];
    var left = [], right = [], pivot = data[0];
    for (var i = 1; i < data.length; i++) {
        if(data[i] < pivot)
    return quicksort(left).concat(pivot, quicksort(right));

Search within Codexpedia

Custom Search

Search the entire web

Custom Search