Selection sort

Run Settings
LanguageJavaScript
Language Version
Run Command
const arr=[0,4,2,1]; function selectionsort(array){ const length=array.length; for(let i=0;i<length;i++){ let minimum_value_position=i; let temp=array[minimum_value_position]; for(let j=i+1;j<length;j++){ if(array[j]<array[minimum_value_position]){ minimum_value_position=j; } } array[i]=array[minimum_value_position]; array[minimum_value_position]=temp; } return array; } selectionsort(arr)
Editor Settings
Theme
Key bindings
Full width
Lines