Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5d12638

Browse files
SidKwoktrekhleb
authored andcommitted
BubbleSort: use Destructuring assignment to swap values (trekhleb#226)
* BubbleSort: use Destructuring assignment to swap values * lint: add semi
1 parent 044441e commit 5d12638

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

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

Lines changed: 1 addition & 3 deletions
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)

AltStyle によって変換されたページ (->オリジナル) /