
10.03.2009, 21:20
|
 |
Гуру
|
|
Регистрация: 09.03.2009
Адрес: На курорте, из окна вижу теплое Баренцево море. Бррр.
Сообщения: 4,723
Репутация: 52347
|
|
Вот вам такое решение:
PHP код:
procedure TForm34.Button1Click(Sender: TObject);
function CustomSort(List: TStringList; Index1, Index2: Integer): Integer;
begin
Result := 0;
if StrToInt(Copy(List[Index1],1,Pos('_',List[Index1])-1)) > StrToInt(Copy(List[Index2],1,Pos('_',List[Index2])-1)) then Result := 1;
if StrToInt(Copy(List[Index1],1,Pos('_',List[Index1])-1)) < StrToInt(Copy(List[Index2],1,Pos('_',List[Index2])-1)) then Result := -1;
end;
var
i: Integer;
Source: TMemo;
List: TStringList;
begin
Source := TMemo.CreateParented(Self.Handle);
Source.Lines.Add('1 2 3 4 5 6');
Source.Lines.Add('7 8 9 0 10');
Source.Lines.Add('11 12 13 20 14');
Source.Lines.Add('15 16 17 18 19');
Memo1.Text := Source.Text;
List := TStringList.Create;
List.Text := '';
for i := 0 to Source.Lines.Count - 1
do List.Text := List.Text + StringReplace(WrapText(Source.Lines[i]+' ',#13#10,[#32],1),#32,'_'+IntToStr(i),[rfReplaceAll]);
List.CustomSort(@CustomSort);
Memo2.Text := List.Text;
end;
|