1function bubbleSort(array) {
2 var done = false;
3 while (!done) {
4 done = true;
5 for (var i = 1; i < array.length; i += 1) {
6 if (array[i - 1] > array[i]) {
7 done = false;
8 var tmp = array[i - 1];
9 array[i - 1] = array[i];
10 array[i] = tmp;
11 }
12 }
13 }
14
15 return array;
16}
17
18var numbers = [12, 10, 15, 11, 14, 13, 16];
19bubbleSort(numbers);
20console.log(numbers);