mirror of
https://github.moeyy.xyz/https://github.com/trekhleb/javascript-algorithms.git
synced 2024-12-25 22:46:20 +08:00
BubbleSort: use Destructuring assignment to swap values (#226)
* BubbleSort: use Destructuring assignment to swap values * lint: add semi
This commit is contained in:
parent
044441e259
commit
5d12638ab5
@ -19,9 +19,7 @@ export default class BubbleSort extends Sort {
|
||||
|
||||
// Swap elements if they are in wrong order.
|
||||
if (this.comparator.lessThan(array[j + 1], array[j])) {
|
||||
const tmp = array[j + 1];
|
||||
array[j + 1] = array[j];
|
||||
array[j] = tmp;
|
||||
[array[j], array[j + 1]] = [array[j + 1], array[j]];
|
||||
|
||||
// Register the swap.
|
||||
swapped = true;
|
||||
|
Loading…
Reference in New Issue
Block a user