Ja. Sorry. Dann stimmt's. Thanx! Hatte ich übersehen. Brauch die Inidces später string kompatibel.
Delphi-Quellcode:
procedure SortKey(const Key: string; Dest: TIntegerList);
var
Ch: Char;
I: Integer;
LastKey: Char;
MinKey: Char;
MinPos: Integer;
begin
Dest.Clear;
if Length(Key) > 0 then
begin
Dest.Add(0); // 1 Basiert weil String kompatibel;
LastKey := #0;
MinKey := #0;
while Dest.Count <= Length(Key) do
begin
MinPos := 0;
for I := 1 to Length(Key) do
begin
Ch := Key[I];
if (Ch > LastKey) and ((MinPos = 0) or (Ch < MinKey)) then
begin
MinKey := Ch;
MinPos := I;
end;
end;
Dest.Add(MinPos);
LastKey := MinKey;
for I := MinPos + 1 to Length(Key) do
if Key[I] = LastKey then
Dest.Add(I);
end;
// for I := 1 to Dest.Count - 1 do ShowMessage(IntToStr(Dest[I]));
end;
end;