function ss(array) { let index = 0; for (let i = 1; i < array.length; i++) { if (array[index] > array[i]) { index = i; } } return index; } function selectionSort(array) { for (let i = 0; i < array.length - 1; i++) { let smallest = i; for (let j = i+1; j < array.length; j++) { if (array[smallest] > array[j]) { smallest = j; } } let temp = array[smallest]; array[smallest] = array[i]; array[i] = temp; } return array; } const notSortedArray = [32, 34, 244, 7, 45, 57, 234, 5, 90, 35, 3546, 567, 32]; const sorted = selectionSort(notSortedArray); console.log(sorted); console.time('selection'); selectionSort(notSortedArray); console.timeEnd('selection');