Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sorting-javascript",
"version": "1.0.3",
"version": "1.0.4",
"description": "Sorting algorithms implemented in JS",
"repository": "neeleshroy/sorting-js",
"author": "Neelesh Roy",
Expand Down Expand Up @@ -57,7 +57,6 @@
"coveralls": "cat ./coverage/lcov.info | coveralls",
"build": "node tools/build",
"prepublish": "npm run build",
"publish": "npm run build && npm publish dist",
"publish:docs": "easystatic deploy docs --repo neeleshroy/sorting-js",
"start": "easystatic start docs"
}
Expand Down
3 changes: 3 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ import { ArrayTestBed } from './utils/ArrayTestBed';
import bubbleSort from './bubble-sort/index';
import insertionSort from './insertion-sort/index';
import selectionSort from './selection-sort/index';
import { mergeSort } from './merge-sort/index';


module.exports = {
ArrayTestBed,
bubbleSort,
insertionSort,
selectionSort,
mergeSort,
};
21 changes: 21 additions & 0 deletions src/quick-sort/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const quickSort = (arr) => {
const unsorted = arr;

if (unsorted.length < 1) {
return unsorted;
}

const pivot = unsorted[unsorted - 1];
const left = [];
const right = [];

for (let i = 0; i < unsorted.length - 1; i++) {
if (unsorted[i] < pivot) {
left.push(unsorted[i]);
} else {
right.push(unsorted[i]);
}
}

return [...quickSort(left), pivot, ...quickSort(right)];
};