Merge pull request #611 from TheAlgorithms/revert-109-patch-1

Revert "Added Sleep Sort"
This commit is contained in:
Rak Laptudirm
2021-05-25 14:11:31 +05:30
committed by GitHub
2 changed files with 0 additions and 19 deletions

View File

@ -254,7 +254,6 @@
* [SelectionSort](https://github.com/TheAlgorithms/Javascript/blob/master/Sorts/SelectionSort.js)
* [SelectionSort](https://github.com/TheAlgorithms/Javascript/blob/master/Sorts/SelectionSort.test.js)
* [ShellSort](https://github.com/TheAlgorithms/Javascript/blob/master/Sorts/ShellSort.js)
* [SleepSort](https://github.com/TheAlgorithms/Javascript/blob/master/Sorts/SleepSort.js)
* [TimSort](https://github.com/TheAlgorithms/Javascript/blob/master/Sorts/TimSort.js)
* [TopologicalSort](https://github.com/TheAlgorithms/Javascript/blob/master/Sorts/TopologicalSort.js)
* [WiggleSort](https://github.com/TheAlgorithms/Javascript/blob/master/Sorts/WiggleSort.js)

View File

@ -1,18 +0,0 @@
/*Sleep sort is a sorting algorithm in which, for every element
to be sorted, we set a timeout for the value of that element.
After the timeout is over, we print the value of the element.
Hence the output is printed in the sorted order.
*/
Array.prototype.sleepSort = function(callback_function) {
const arr = [];
for (let n of this)
setTimeout(() => {
arr.push(n);
if (this.length === arr.length)
callback_function(arr);
}, n + 1);
return arr;
};
[1, 9, 8, 7, 6, 5, 3, 4, 5, 2, 0].sleepSort(console.log);