From 8d1278b4559e1fe460d7aae3d20ddec460b61910 Mon Sep 17 00:00:00 2001 From: marsonya Date: Mon, 2 Nov 2020 15:26:47 +0530 Subject: [PATCH] Cocktail Shaker Sort | Added Doctests --- Sorts/CocktailShakerSort.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Sorts/CocktailShakerSort.js b/Sorts/CocktailShakerSort.js index f32a1f2ad..a6e13548f 100644 --- a/Sorts/CocktailShakerSort.js +++ b/Sorts/CocktailShakerSort.js @@ -8,6 +8,18 @@ * 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) { for (let i = items.length - 1; i > 0; i--) { let j