ListBox sorting

I have a ListBox where I need to accumulate the values in 2 of the columns after sorting one of the other columns. Consider.

a 4 0
d 3 0
c 9 0
f 2 0
g 8 0
e 7 0

I need the following:

a 4 4
c 9 13
d 3 16
e 7 23
f 2 25
g 8 33

What is the best and quickest way to achieve this?

Thanks

Terry

I’d read the values of your two columns into two arrays (first textual, second integer), use something like textualArray.SortWith(integerArray), then repopulate the rows of the listBox; while doing so, keep a running total to put into the third column.

Using your example, I’d sort on the first column then loop through the rows looking at column 2 and keeping a running total which I’d then stuff into the cell at column three of that row.

Basically, get the data in the order you want it in and then go process that data.