
24.05.2013, 06:40
|
 |
LMD-DML
|
|
Регистрация: 12.07.2009
Адрес: Богородское
Сообщения: 3,025
Версия Delphi: D7E
Репутация: 1834
|
|
Вот ещё вариант
Код:
procedure SortToTableDesc(StrGrid: TStringGrid; SortColumn: integer);
function Uslovie(s2, s1: string): boolean;
var vl1, vl2:Extended;
begin
if tryStrtoFloat(s1,vl1) and tryStrtoFloat(s2,vl2) then
Result:= vl1 > vl2 else Result:= s1 > s2;
end;
var i, j, k: integer;
sTemp: string;
begin
with StrGrid do
for i := FixedRows to RowCount-2 do
for j := i + 1 to RowCount-1 do
if Uslovie(Cells[SortColumn, i], Cells[SortColumn, j]) then
for k := FixedCols to ColCount-1 do
begin
sTemp:= Cells[k, i];
Cells[k, i]:= Cells[k, j];
Cells[k, j]:= sTemp;
end;
end;
|