diff --git a/src/selection.ts b/src/selection.ts index fe85358..75cf2e1 100644 --- a/src/selection.ts +++ b/src/selection.ts @@ -13,9 +13,10 @@ export function selectionSort(arr: T[], compareFn: CompareFn): T[] { } if (minIndex !== i) { - const temp = sortedArray[i]; - sortedArray[i] = sortedArray[minIndex]; - sortedArray[minIndex] = temp; + [sortedArray[i], sortedArray[minIndex]] = [ + sortedArray[minIndex], + sortedArray[i], + ]; } }