Link to home
Start Free TrialLog in
Avatar of tflarsen
tflarsen

asked on

Sorting a 4 dimensional array

My program reads a text file with data in 4 columns.

I need to sort the file based on the data in the first column. My program already uses a listbox for other things and I'd prefer to use another listbox for this matter too.
I load all the data into a 4 dimensional array and I tried putting the data into an indexed listbox with the sort set to True. The problem is that it sorts all 4 dimensions and not only the first one, meaning that the data is mixed up.

Is there an easy way of sorting this array?

Any help is appreciated.
Teddy
Avatar of peterprice
peterprice

Try Using  a Grid instead. Place alll 4 colums of data in a grid and then load your list box with the Data from The first Grid Column and the row number into the index. and then sort the list box.
Avatar of tflarsen

ASKER

I know that solution already, but I'm not using the grid control anywhere else in my program and I'm trying to make this program as small as possible.

Do you know any other solutions?
Place only the column you wish to sort on into the ListBox. Set each item's ItemData to its original index in the array. That way you can know which entry in the array is refererd to by each entry in the ListBox.

Hope this helps... ask if you want a code sample.

I'd like the example please. I think I know what you are thinking about but I'd like to be 100% sure about it.

Thnx so far.

I'm going to reopen the question so you can get the points.
ASKER CERTIFIED SOLUTION
Avatar of alamo
alamo

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial