That "for( i in items )" loop isn't guaranteed to enumerate the items in any
particular order. If you need something to be in a particular order, don't
use an object with string property names. Use an array, e.g.
var items = [
"101010111110010101020110111110100010101020101020101010101100110100",
"000010101210101011100101101010000111111001010121010000111110001111",
...
];
Then you can code:
var classes = [ 'grey', 'blue', 'red' ];
var html = [], h = -1;
html[++h] = '<div>';
for( var item, i = -1; item = items[++i]; ) {
html[++h] = '<div class="row">';
var values = item.split('');
for( var value, j = -1; value = values[++j]; ) {
html[++h] = '<div class="';
html[++h] = classes[+value];
html[++h] = '"> </div>';
}
html[++h] = '</div>';
}
html[++h] = '</div>';
html = html.join('');
I added a wrapper div around each row with class="row" - my guess is you
probably need something like that, because you want this to be a
two-dimensional display, right?
-Mike