| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 
 | function selectionsort(arr){const len = arr.length;
 let sortIndex = 0
 while(sortIndex < len){
 
 
 let minIndex = sortIndex
 
 for(let i=sortIndex;i<len;i++){
 
 if(arr[i] < arr[minIndex]){
 minIndex = i
 }
 
 }
 [arr[sortIndex],arr[minIndex]] = [arr[minIndex],arr[sortIndex]]
 sortIndex++
 }
 return arr
 }
 selectionsort([45,
 50,
 32,
 4,
 37,
 10,
 47,
 44,
 17,
 38,
 26,
 25,
 37,
 17,
 1,
 3,
 7])
 
 
 
 
 
 
 
 
 
 |