From d88e28df6cde0c7a4174ab0fbb4aa3a29b660339 Mon Sep 17 00:00:00 2001 From: Neelesh Roy Date: Sat, 12 May 2018 12:32:18 +0530 Subject: [PATCH 1/3] recurring publish build --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index 0444e4b..80bc458 100644 --- a/package.json +++ b/package.json @@ -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" } From daf6755899a0b4283a162bebf2a37826d29879b2 Mon Sep 17 00:00:00 2001 From: Neelesh Roy Date: Sat, 12 May 2018 12:36:39 +0530 Subject: [PATCH 2/3] 1.0.3 deploy --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 80bc458..094af14 100644 --- a/package.json +++ b/package.json @@ -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", From ba819b83ee343794c335741c8bee0953dd19ec69 Mon Sep 17 00:00:00 2001 From: Neelesh Roy Date: Sat, 12 May 2018 14:53:54 +0530 Subject: [PATCH 3/3] quicksort --- src/index.js | 3 +++ src/quick-sort/index.js | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 src/quick-sort/index.js diff --git a/src/index.js b/src/index.js index a52fa97..542d3ee 100644 --- a/src/index.js +++ b/src/index.js @@ -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, }; diff --git a/src/quick-sort/index.js b/src/quick-sort/index.js new file mode 100644 index 0000000..4112be9 --- /dev/null +++ b/src/quick-sort/index.js @@ -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)]; +};