I have a custom sorted TStringList
...
Items.CustomSort(@CompareWords);
... with this comparison function:
function CompareWords(List: TStringList; Index1, Index2: Integer): Integer;
begin
Result := StrIComp(PWideChar(List[Index1]), PWideChar(List[Index2]));
end;
But after noticing some problems with my code, which expects the list to be sorted in the order StrIComp
induces, I created this small check...
for i := 1 to Items.Count - 1 do
begin
Assert(StrIComp(PWideChar(Items[i-1]), PWideChar(Items[i])) <= 0);
end;
... and it fails.
Why isn't the list sorted properly?