Skip to content

Commit 9f21e42

Browse files
committed
Lint bubbleSort.
1 parent 7eb40fd commit 9f21e42

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/sort/bubbleSort.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,21 @@ function bubbleSort<T>(list: List<T>, predicate: (a: Node<T>, b: Node<T>) => boo
1414
throw new TypeError('Invalid arguments: list and predicate are required');
1515
}
1616

17-
let left = list.head;
18-
let swapped;
17+
let left = list.head
18+
let swapped: boolean
1919

2020
do {
21-
swapped = false;
22-
let right = left;
21+
swapped = false
22+
let right = left
2323

2424
while (right && right.next) {
2525
if (predicate(right, right.next)) {
26-
list.swap(right, right.next); // soft swap
27-
swapped = true;
26+
list.swap(right, right.next) // soft swap
27+
swapped = true
2828
}
29-
right = right.next;
29+
right = right.next
3030
}
31+
3132
left = left?.next || null;
3233
} while (swapped);
3334
}

0 commit comments

Comments
 (0)