function selectSort(arr) { let i = 0; while(i < arr.length - 1) { let j = i; while(j < arr.length) { if (arr[j] < arr[i]) { [arr[i], arr[j]] = [arr[j], arr[i]]; } j++ } i++ } return arr } console.log(selectSort([3, 9, 2, 1, 5, 7]))