const arr=[3,4,2,5,1,6,8,7,9]
~function fn(){
let temp
for (let p=0;p<=arr.length-2;p++){
let smallest=arr[p]
let smallestIndex=p
for(let i=p;i<=arr.length;i++){
if(arr[i]<arr[p]){
smallest=arr[i]
smallestIndex=i
}
}
temp=arr[p]
arr[p]=smallest
arr[smallestIndex]=temp
}
console.log(arr);
}