uses
Classes, SysUtils;
function GetTextCol(
const AValue:
string; AIndex: Integer):
string;
var
iPos: Integer;
begin
Result := AValue;
{Spalten 0 .. AIndex-1 löschen}
while AIndex > 0
do
begin
iPos := Pos(Char(#9), Result);
if iPos = 0
then
begin
Result := '
';
Exit;
end;
Delete(Result, 1, iPos);
Dec(AIndex);
end;
{Spalten AIndex+1 löschen}
iPos := Pos(Char(#9), Result);
if iPos > 0
then
Delete(Result, iPos, Length(Result));
end;
function MyCompareFn(List: TStringList; Index1, Index2: Integer): Integer;
var
s1, s2:
string;
begin
s1 := GetTextCol(List[Index1], 1);
s2 := GetTextCol(List[Index2], 1);
if List.CaseSensitive
then
Result := AnsiCompareStr(s1, s2)
else
Result := AnsiCompareText(s1, s2);
end;
var
SL: TStringList;
begin
SL := TStringList.Create;
try
SL.LoadFromFile('
Text.txt');
SL.CustomSort(MyCompareFn);
SL.SaveToFile('
MyText.txt');
finally
SL.Free;
end;
end;