1function sortArray(array) {
2 var temp = 0;
3 for (var i = 0; i < array.length; i++) {
4 for (var j = i; j < array.length; j++) {
5 if (array[j] < array[i]) {
6 temp = array[j];
7 array[j] = array[i];
8 array[i] = temp;
9 }
10 }
11 }
12 return array;
13}
14
15console.log(sortArray([3,1,2]));