Multi-column two-dimensional quick sort

M

Marston

Hi -

I've gone through many of the old posts on quick sorting and haven't
quite come across what I think would solve my problem.

I have a very large array that has been loaded from multiple
worksheets.
In general, its somewhere in the neighborhood of 100,000 rows x 10
columns.

What I'd like to do is sort all the information based first on the
values in each of the rows and one of the columns and then within that
set, sorting on a second column, and so on until the entire array has
been sorted by each of the columns.

What I've seen will sort on any one column within a 2-d array, but not
multiple columns.

Thanks in advance
 
J

Jamie Collins

...
You could try loading the data into an ADO recordset and using the
recordset's sort method.

A good suggestion. However, rather than fabricating a recordset based
on the array, the OP may be able to create the recordset already
populated *and* sorted using the worksheet data, all in one query e.g.

SELECT
MyCol1 AS Col1,
MyCol2 AS Col2,
MyCol3 AS Col3,
MyCol3 AS Col4
FROM
[Sheet1$]
UNION
SELECT
MyColA AS Col1,
MyColB AS Col2,
MyColC AS Col3,
MyColD AS Col4
FROM
[Sheet2$]
ORDER BY
1,2,3,4
;

If you then need an array, use the recordset's GetRows method.

Jamie.

--
 
M

Marston

Actually - I thought of another way.
Since none of my column data are zero valuded (and never will be)
I've added another column of data to my dataset that effectivley is
the concatenation of the info I want to sort in the order I want it
sorted.
Then I can run a quick sort on that column and everything will be as I
want.


...
You could try loading the data into an ADO recordset and using the
recordset's sort method.

A good suggestion. However, rather than fabricating a recordset based
on the array, the OP may be able to create the recordset already
populated *and* sorted using the worksheet data, all in one query e.g.

SELECT
MyCol1 AS Col1,
MyCol2 AS Col2,
MyCol3 AS Col3,
MyCol3 AS Col4
FROM
[Sheet1$]
UNION
SELECT
MyColA AS Col1,
MyColB AS Col2,
MyColC AS Col3,
MyColD AS Col4
FROM
[Sheet2$]
ORDER BY
1,2,3,4
;

If you then need an array, use the recordset's GetRows method.

Jamie.

--
 
Top