Skip to content

Commit e5f3d23

Browse files
png261vil02
andauthored
refactor: use method SortUtils.swap (TheAlgorithms#4946)
* refactor: use method SortUtils.swap * fix: clang format * style: explicitly import `swap` --------- Co-authored-by: Piotr Idzik <65706193+vil02@users.noreply.github.com>
1 parent 945e7b5 commit e5f3d23

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/main/java/com/thealgorithms/sorts/SelectionSort.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.thealgorithms.sorts;
22

3+
import static com.thealgorithms.sorts.SortUtils.swap;
4+
35
public class SelectionSort implements SortAlgorithm {
46

57
/**
@@ -20,9 +22,7 @@ public <T extends Comparable<T>> T[] sort(T[] arr) {
2022
}
2123
}
2224
if (minIndex != i) {
23-
T temp = arr[i];
24-
arr[i] = arr[minIndex];
25-
arr[minIndex] = temp;
25+
swap(arr, i, minIndex);
2626
}
2727
}
2828
return arr;

0 commit comments

Comments
 (0)