Skip to content

Commit 5d12638

Browse files
SidKwoktrekhleb
authored andcommittedOct 17, 2018
BubbleSort: use Destructuring assignment to swap values (trekhleb#226)
* BubbleSort: use Destructuring assignment to swap values * lint: add semi

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed
 

‎src/algorithms/sorting/bubble-sort/BubbleSort.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ export default class BubbleSort extends Sort {
1919

2020
// Swap elements if they are in wrong order.
2121
if (this.comparator.lessThan(array[j + 1], array[j])) {
22-
const tmp = array[j + 1];
23-
array[j + 1] = array[j];
24-
array[j] = tmp;
22+
[array[j], array[j + 1]] = [array[j + 1], array[j]];
2523

2624
// Register the swap.
2725
swapped = true;

0 commit comments

Comments
 (0)
Please sign in to comment.