From e5f3d232c9fb97ed350a57708fc29d30fa0b28ae Mon Sep 17 00:00:00 2001 From: Phuong Nguyen Date: Tue, 31 Oct 2023 05:09:43 +0700 Subject: [PATCH] refactor: use method `SortUtils.swap` (#4946) * refactor: use method SortUtils.swap * fix: clang format * style: explicitly import `swap` --------- Co-authored-by: Piotr Idzik <65706193+vil02@users.noreply.github.com> --- src/main/java/com/thealgorithms/sorts/SelectionSort.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/thealgorithms/sorts/SelectionSort.java b/src/main/java/com/thealgorithms/sorts/SelectionSort.java index 555b4b603..e43df7fe6 100644 --- a/src/main/java/com/thealgorithms/sorts/SelectionSort.java +++ b/src/main/java/com/thealgorithms/sorts/SelectionSort.java @@ -1,5 +1,7 @@ package com.thealgorithms.sorts; +import static com.thealgorithms.sorts.SortUtils.swap; + public class SelectionSort implements SortAlgorithm { /** @@ -20,9 +22,7 @@ public class SelectionSort implements SortAlgorithm { } } if (minIndex != i) { - T temp = arr[i]; - arr[i] = arr[minIndex]; - arr[minIndex] = temp; + swap(arr, i, minIndex); } } return arr;