Skip to content

Commit 8d1278b

Browse files
committed
Cocktail Shaker Sort | Added Doctests
1 parent aab8a55 commit 8d1278b

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Sorts/CocktailShakerSort.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,18 @@
88
* Wikipedia (Bubble Sort): https://en.wikipedia.org/wiki/Bubble_sort
99
*
1010
*/
11+
12+
/**
13+
* Doctests
14+
*
15+
* > cocktailShakerSort([5, 4, 1, 2, 3])
16+
* [1, 2, 3, 4, 5]
17+
* > cocktailShakerSort([])
18+
* []
19+
* > cocktailShakerSort([1, 2, 3])
20+
* [1, 2, 3]
21+
*/
22+
1123
function cocktailShakerSort (items) {
1224
for (let i = items.length - 1; i > 0; i--) {
1325
let j

0 commit comments

Comments
 (0)