In the array, each item is placed on the stage with an x/y position. The top left most position should be items[0], with X as the primary positioning factor.
Initially, I considered using the following code:
var items = [m1, m2, m3, m4, m5, m6];
items.sort(sortMe);
function sortMe(a, b)
{
return (b.position[0] - a.position[0]) && (b.position[1] - a.position[1]);
}
However, this approach did not deliver the desired results.