Dec 16, 2014, 2:25:15 AM12/16/14
I am trying to sort a stringgrid by using a bubblesort procedure that I have found on the internet and with some small modification I have made it work.
I am a newbie when it comes to programming in delphi so I need some help to make this bubblesort program look in an other column aswell.
At the moment I have a stringgrid that I sort with column 1 (a-z) but I can have multiple entrys of eg. aaaa in column 1 so I need to look up column 4 to check the revision (numbers 1 and up).
My code looks like this:
procedure TForm1.SortGrid(Grid: TStringGrid; Col: integer);
Row, AllRowCount: integer;
for AllRowCount:= 0 to Grid.RowCount- 1 do
for Row:= 2 to Grid.RowCount- 1 do
if ((Grid.Cells[Col, Row]) <> '') then
if ((Grid.Cells[Col, Row-1])<> '') then
if (Grid.Cells[Col, Row]) < (Grid.Cells[Col, Row-1]) then
prev:= Grid.Rows[Row- 1].CommaText;
Grid.Rows[Row- 1].CommaText:= Grid.Rows[Row].CommaText;
Thanks in advance for your help