Merge pull request #1823 from h20x/fix-bubble-sort

This commit is contained in:
Angelos Chalaris
2021-07-13 18:30:04 +03:00
committed by GitHub

View File

@ -17,7 +17,7 @@ Sorts an array of numbers, using the bubble sort algorithm.
const bubbleSort = arr => {
let swapped = false;
const a = [...arr];
for (let i = 1; i < a.length - 1; i++) {
for (let i = 1; i < a.length; i++) {
swapped = false;
for (let j = 0; j < a.length - i; j++) {
if (a[j + 1] < a[j]) {