reorder boxes according to array