I am working with Lazarus. I have two TStringList, after I sort them, I show them to screen. But the order is wrong. I am impossible to determine how it was wrong.
This is screenshot when the TStringList is not sorted:
After I call FMover.AList.Sort and FMover.BList.Sort, I show them to screen. This is screenshot after the lists is sorted.
You can see, item '.../kam14.in' is appeared before '.../kam1.in'. Sort procedure is not working properly.
This is some procedure used in the program.
procedure TAddProblemForm.actRegexLoadExecute(Sender: TObject);
var
ARegExpr, BRegExpr: TRegExpr;
s: String;
AExpr, BExpr: String;
Form: TRegexOptionForm;
begin
Form := TRegexOptionForm.Create(Self);
if Form.Execute('in', 'out') = mrOK then
begin
ARegExpr:=TRegExpr.Create;
BRegExpr:=TRegExpr.Create;
FMover.Clear;
ARegExpr.Expression := Form.AExpr;
BRegExpr.Expression := Form.BExpr;
AddSearchResult(FMover.List, SearchDir, true);
for s in FMover.List do
begin
if ARegExpr.Exec(s) then
FMover.AList.Add(s)
else if BRegExpr.Exec(s) then
FMover.BList.Add(s);
end;
// *******************
actInvalidate.Execute;
FMover.AList.Sort;
FMover.BList.Sort;
actInvalidate.Execute;
// *******************
ARegExpr.Free;
BRegExpr.Free;
end;
Form.Free;
end;
And another
procedure TAddProblemForm.actInvalidateExecute(Sender: TObject);
var
s: String;
begin
ListBox1.Clear;
ListBox2.Clear;
for s in FMover.AList do
ListBox1.Items.Add(s);
for s in FMover.BList do
ListBox2.Items.Add(s);
Application.ProcessMessages;
end;