So, the question is how to transpose (shift) group of cells depending on the value of one cell within certain group.

Lets say we got three groups (red, blue and yellow) of cells (filled with some informations), for example 5 cells width and 8 cells height. They are mutually divided by one row. One cell within group determines value of that group. Red group has value of 500, blue group has value of 400 and yellow group has value of 300, so cells should be ordered from left to right: red, blue and yellow. If we change value of yellow group into 600, it should take position of red group, the red group should take position of blue group and the blue group should take position of yellow group.

The big question, is it possible to do this?

In my project there are like 10-20 groups, so it should be considered also.

Thanks in advance.