enh(Javascript): Delay swapping (#653)
parent
ca62f9158c
commit
e8bb90680d
|
@ -8,13 +8,12 @@ function selectionSort(array) {
|
|||
if (array[j] < array[i]) {
|
||||
minIndex = j;
|
||||
}
|
||||
|
||||
}
|
||||
// swap with element at minimum index
|
||||
const temp = array[minIndex];
|
||||
array[minIndex] = array[i];
|
||||
array[i] = temp;
|
||||
}
|
||||
}
|
||||
|
||||
// return sorted array
|
||||
return array;
|
||||
|
|
Loading…
Reference in New Issue