<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<script type="text/javascript">
var arr = [10,50,415,15,155,1532,5641,845,2,10,48,65];
function fun(arr){
for(var i = 0;i < arr.length-1;i++){
for(var j =0;j < arr.length-i-1;j++){
if(arr[j] > arr[j+1]){
var arr_old = arr[j]
arr[j] = arr[j+1];
arr[j+1] = arr_old;
}
}
}
return arr;
}
fun(arr);
console.log(arr)
</script>
</body>
</html>