Swap as destructuring assignment (#497)

This commit is contained in:
vladimirschneider 2020-07-26 18:21:13 +07:00 committed by GitHub
parent 194f2133af
commit 2ffb7b7abf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -21,9 +21,7 @@ export default class InsertionSort extends Sort {
this.callbacks.visitingCallback(array[currentIndex - 1]);
// Swap the elements.
const tmp = array[currentIndex - 1];
array[currentIndex - 1] = array[currentIndex];
array[currentIndex] = tmp;
[array[currentIndex - 1], array[currentIndex]] = [array[currentIndex], array[currentIndex - 1]];
// Shift current index left.
currentIndex -= 1;