icqprophet,
Вариант отрисовки пирамид
<script type="text/javascript">
var arr = [40,7,6,5,8,2,0,3,1,12,4,7,6,5,8,2,0,3,12,4,7,6,5,8,2,0,3,1,12,4,7,6,5,8,2,7];
function sort(c) {
for (var e = c.length; e--;) {
for (var a = c;;) {
for (var d = !0, b = 0; b < (e - 1) / 2; b++)
a[b] < a[2 * b + 1] && (d = a[b], a[b] = a[2 * b + 1], a[2 * b + 1] = d, d = !1),
a[b] < a[2 * b + 2] && (d = a[b], a[b] = a[2 * b + 2], a[2 * b + 2] = d, d = !1);
if (d) break
}
for (var i=1; i < e; i*=2) {
for (var k=i-1; k < i*2-1; k++) {
if(k<e) document.write(c[k]+" ")
}
document.write("<br />")
}
document.write("<br /><br /><br />")
if(c[0] > c[e]) {a = c[0];c[0] = c[e];c[e] = a}
}
return c
};
sort(arr)
</script>