# How can I build a GraphicsGrid of fixed size that rearranges the empty plots?

OK, let's make one final attempt; they say the third time is the lucky one! Following @rm-rf 's suggestions, I will try to be as clear as I can.

My Mathematica code reads and plots simultaneously some data files. The output of the function plo below can be either a Graphics object (ListPlot) or a null string ("") if the data it reads doesn't exist. I want to arrange the 20 plots below in a grid of fixed dimensions ($4 \times 4 \times 4 \times 4 \times 2 \times 2$) like so:

P0 = Show[GraphicsGrid[{
{plo[1, 1], plo[2, 1], plo[4, 1], plo[7, 1]},
{plo[1, 2], plo[3, 1], plo[5, 1], plo[7, 2]},
{plo[1, 3], plo[3, 2], plo[6, 1], plo[8, 1]},
{plo[1, 4], plo[3, 3], plo[6, 2], plo[8, 2]},
{plo[1, 5], plo[3, 4]},
{plo[1, 6], plo[3, 5]}}]]


Since some data files may not exist, I would like the plots to rotate so that there are no blank spaces in between the plots but all the Null plots get moved to the end of the grid. For example, if plo[2, 1], plo[7, 2] are missing I would like them to take up the last two slots in my grid while the rest of the plots preserve their ordering.

-

Ok, here goes (again). (Probably) replacing this line:

P0 = Show[GraphicsGrid[{
{plo[1, 1], plo[2, 1], plo[4, 1], plo[7, 1]},
{plo[1, 2], plo[3, 1], plo[5, 1], plo[7, 2]},
{plo[1, 3], plo[3, 2], plo[6, 1], plo[8, 1]},
{plo[1, 4], plo[3, 3], plo[6, 2], plo[8, 2]},
{plo[1, 5], plo[3, 4]},
{plo[1, 6], plo[3, 5]}}


with this

Module[{list, newlist},
list=Select[Flatten[{
{plo[1, 1], plo[2, 1], plo[4, 1], plo[7, 1]},
{plo[1, 2], plo[3, 1], plo[5, 1], plo[7, 2]},
{plo[1, 3], plo[3, 2], plo[6, 1], plo[8, 1]},
{plo[1, 4], plo[3, 3], plo[6, 2], plo[8, 2]},
{plo[1, 5], plo[3, 4]},
{plo[1, 6], plo[3, 5]}}],! StringQ@#&];