mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-06 09:28:26 +08:00
Cocktail Shaker Sort | Code wasn't returning sorted Items. Changed that.
This commit is contained in:
@ -10,7 +10,6 @@
|
||||
*/
|
||||
function cocktailShakerSort (items) {
|
||||
for (let i = items.length - 1; i > 0; i--) {
|
||||
let swapped = false
|
||||
let j
|
||||
|
||||
// Backwards
|
||||
@ -28,10 +27,9 @@ function cocktailShakerSort (items) {
|
||||
swapped = true
|
||||
}
|
||||
}
|
||||
if (!swapped) {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
return items
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user