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>
This commit is contained in:
Phuong Nguyen 2023-10-31 05:09:43 +07:00 committed by GitHub
parent 945e7b56bb
commit e5f3d232c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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;