Sorting virtual data

Hello,


I have found that sorting is far too slow in TAdvStringGrid (the problem is properbly TStringGrid actually). I used a TListView before and i now using the TAdvStringGrid. It's great for most purposes, but the sorting is simply too slow, I think.
I am using virtual cells, so I have the data in another structure. Sorting in this structure is very fast.

I would prefer to use as much as possible of the AdvStringGrid functionality like triggering sort by clicking the column header, display the column that is sorted etc.

What is the best way to do this?

Please see:

http://www.tmssoftware.com/site/asg45.asp

Thank you for this very fast reply, but unless I have misunderstood something, it doesn't really help me.
My problem was that the sorting is too slow. 



In the sample that you refer to, I have tried to use a TList<integer> instead of the array.
When I click a column in the stringgrid the sorting takes a couple of seconds for 80.000 rows. If I instead call:
  Values.Sort; // internal sort of TList<integer>
  AdvStringGrid1.Invalidate;
then the (same) sorting takes under half a second. 

Even if I use virtual cells the AdvStringGrid is swapping rows in the stringgrid (slow string manipulation):
TAdvStringGrid.SortSwapRows:
  SortList.Assign(Rows[ARow1]);
  Rows[ARow1] := Rows[ARow2];
  Rows[ARow2].Assign(SortList);
Among other things, this means that the sorting is not very fast.

So, what I was hoping for was that I could sort the internal structure myself (in this case the TList<integer>) and still use the already written code in the AdvStringGrid for clicking on a column header, displaying which column is sorted etc.
(Of course, the best solution would be if the sorting was faster in the AdvStringGrid)