diff --git a/src/algorithms/sorting/insertion-sort/InsertionSort.js b/src/algorithms/sorting/insertion-sort/InsertionSort.js index 47262548..ff53c5a6 100644 --- a/src/algorithms/sorting/insertion-sort/InsertionSort.js +++ b/src/algorithms/sorting/insertion-sort/InsertionSort.js @@ -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;