Показать сообщение отдельно
  #4  
Старый 29.02.2012, 18:17
Аватар для YVitaliy
YVitaliy YVitaliy вне форума
Местный
 
Регистрация: 14.12.2011
Сообщения: 481
Версия Delphi: Borland Delphi7
Репутация: 17
По умолчанию

Код:
procedure SortStringGrid(var GenStrGrid: TStringGrid; ThatCol: Integer);
const
  TheSeparator = '@';
var
  CountItem, I, J, K, ThePosition: integer;
  MyList: TStringList;
  MyString, TempString: string;
begin
  CountItem := GenStrGrid.RowCount;
  MyList        := TStringList.Create;
  MyList.Sorted := False;
  try
    begin
      for I := 1 to (CountItem - 1) do
        MyList.Add(GenStrGrid.Rows[I-1].Strings[ThatCol] + TheSeparator + //тут
          GenStrGrid.Rows[I-1].Text);
      Mylist.Sort;
      for K := 1 to Mylist.Count do
      begin
        MyString := MyList.Strings[(K - 1)];
        ThePosition := Pos(TheSeparator, MyString);
        TempString  := '';
        {Eliminate the Text of the column on which we have sorted the StringGrid}
        TempString := Copy(MyString, (ThePosition + 1), Length(MyString));
        MyList.Strings[(K - 1)] := TempString;
      end;
      for J := 1 to (CountItem - 1) do
        GenStrGrid.Rows[J-1].Text := MyList.Strings[(J - 1)]; // тут
    end;
  finally
    MyList.Free;
  end;
end;
А твоя сортировка - это что, типа пузырьковый метод? А то я в ней не разобрался Не думаю, что этот метод намного быстрее будет.
Ответить с цитированием