OK,
I did something similar to this getting data from a database once before.

I had a number of tables in the db with columns for date, time, data1, data2 etc.
What I wanted to do was sort the data before displaying it in a grid.
So, what I did was read the data into zero width (hidden) columns in the grid and then, when I had finished reading the database, transfer the data from the hidden columns to the visible columns.

In your case, after you have finished reading the db, you will see that some of the hidden columns are empty. Therefore you would make the corresponding (normally visible) column invisible also.

If you have a lot of data to read and sort, you could display a progress bar or some sort of file loading .ani