Fix bubbleSort
This commit is contained in:
@ -17,7 +17,7 @@ Sorts an array of numbers, using the bubble sort algorithm.
|
|||||||
const bubbleSort = arr => {
|
const bubbleSort = arr => {
|
||||||
let swapped = false;
|
let swapped = false;
|
||||||
const a = [...arr];
|
const a = [...arr];
|
||||||
for (let i = 1; i < a.length - 1; i++) {
|
for (let i = 1; i < a.length; i++) {
|
||||||
swapped = false;
|
swapped = false;
|
||||||
for (let j = 0; j < a.length - i; j++) {
|
for (let j = 0; j < a.length - i; j++) {
|
||||||
if (a[j + 1] < a[j]) {
|
if (a[j + 1] < a[j]) {
|
||||||
|
|||||||
Reference in New Issue
Block a user