<html>
<head>
<script>
var arr = [5, 6, 3, 10, 7, 2, 1, 4, 9];
function bubbleSort(arr) {
var i, j;
for (i = arr.length - 1; i >= 0; i--) {
for (j = 0; j <= i; j++) {
if (arr[j + 1] < arr[j]) {
var temp = arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = temp;
}
}
}
return arr;
}
document.writeln(arr+"<br>");
document.write(bubbleSort(arr));
</script>
</head>
<body>
</body>
</html>