Cocktail Shaker Sort | Added Doctests

This commit is contained in:
marsonya
2020-11-02 15:26:47 +05:30
parent aab8a555fc
commit 8d1278b455

View File

@ -8,6 +8,18 @@
* Wikipedia (Bubble Sort): https://en.wikipedia.org/wiki/Bubble_sort * Wikipedia (Bubble Sort): https://en.wikipedia.org/wiki/Bubble_sort
* *
*/ */
/**
* Doctests
*
* > cocktailShakerSort([5, 4, 1, 2, 3])
* [1, 2, 3, 4, 5]
* > cocktailShakerSort([])
* []
* > cocktailShakerSort([1, 2, 3])
* [1, 2, 3]
*/
function cocktailShakerSort (items) { function cocktailShakerSort (items) {
for (let i = items.length - 1; i > 0; i--) { for (let i = items.length - 1; i > 0; i--) {
let j let j