I try to sort an TStringList on the Name part. For do that, I use the customSort method.
I show you a little example :
function CompareString(List : TStringList; Index1, Index2 : integer) : integer;
begin
result := AnsiCompareText(List.Names[Index1], List.Names[Index2]);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Memo2.Clear;
Liste.CustomSort(CompareString);
Memo2.Lines.Append(Liste.GetText)
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Liste := TStringList.Create;
Liste.Append('INFOS_NEGOCE=NUM_CDE');
Liste.Append('INFOS_NEGOCE=DATE_CDE');
Liste.Append('INFOS_NEGOCE=NOM_REPERTOIRE_ENT');
Liste.Append('INFOS_NEGOCE=NOM_CONTACT');
Memo1.Lines.Clear;
Memo1.Lines.Append(Liste.GetText)
end;
The sort give me this result :
INFOS_NEGOCE=NOM_REPERTOIRE_ENT
INFOS_NEGOCE=NOM_CONTACT
INFOS_NEGOCE=NUM_CDE
INFOS_NEGOCE=DATE_CDE
I think that the sort DON'T change the order of the line (the name is always INFOF_NEGOCE).