procedure GridSort(StrGrid: TStringGrid; NoColumn: Integer); var Line, PosActual: Integer; Row: TStringList; Renglon :TStringList; begin Renglon := TStringList.Create; Row := TStringList.Create; for Line := 0 to StrGrid.RowCount-1 do begin PosActual := Line; Row.Assign(StrGrid.Rows[PosActual]); while True do begin if (PosActual = 0) or (Row.Strings[NoColumn] >= StrGrid.Cells[NoColumn,PosActual-1]) then break; StrGrid.Rows[PosActual] := StrGrid.Rows[PosActual-1]; Dec(PosActual); end; if (Row.Strings[NoColumn] < StrGrid.Cells[NoColumn,PosActual]) then StrGrid.Rows[PosActual].Assign(Row); end; Row.Free; Renglon.Free; end; The code above sorts one column by GridSort(StringGrid1, 1); And it works like this:
It is possible to modify the code so that I select the cell "KSK12" in the first column (that is, any non-alphabetical group), and he brought me the first lines with "KSK12" and alphabetical names, and then other groups went. And how to make, that did not affect the fixed lines?