mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-06 17:50:39 +08:00
Cocktail Shaker Sort | Added Doctests
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user