diff --git a/src/main/kotlin/codecollection/algorithms/SelectionSort.kt b/src/main/kotlin/codecollection/algorithms/SelectionSort.kt index 0dd6007..42727fa 100644 --- a/src/main/kotlin/codecollection/algorithms/SelectionSort.kt +++ b/src/main/kotlin/codecollection/algorithms/SelectionSort.kt @@ -1,7 +1,5 @@ package codecollection.algorithms -import java.util.Collections - fun selectionSort(list: List): List { if (list.size <= 1) return list val result = list.toMutableList() @@ -10,7 +8,7 @@ fun selectionSort(list: List): List { for (j in i + 1 until result.size) { if (result[j] < result[minIndex]) minIndex = j } - if (minIndex != i) Collections.swap(result, minIndex, i) + if (minIndex != i) result[minIndex] = result[i].also { result[i] = result[minIndex] } } return result }