var m = [1, 2, 3, 4, 10, 6, 7, 8, 9, 5];
var count = m.length-1;
for (var i = 0; i < count; i++)
for (var j = 0; j < count-i; j++)
if (m[j]> m[j+1]) {
var max = m[j];
m[j] = m[j+1];
m[j+1] = max;
}
document.write(m);
Bubble sorting example
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.