Skip to content

Instantly share code, notes, and snippets.

@goesang
Created June 23, 2015 15:03
Show Gist options
  • Save goesang/6e3dc4fd9105ab7dee97 to your computer and use it in GitHub Desktop.
Save goesang/6e3dc4fd9105ab7dee97 to your computer and use it in GitHub Desktop.
선택 정렬 자바스크립트 간단 버젼.
function selectionSort(arr){
for(var i = 0;i<arr.length;i++)
for(var j = i+1;j<arr.length;j++)
if(arr[i]>arr[j]){
var tmp = arr[j];
arr[j] = arr[i];
arr[i] = tmp;
}
return arr;
}
alert(selectionSort([0,50,6,3,5,2,1,2]));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment