gpt4 book ai didi

delphi - 为什么我的 TStringList 没有排序?

转载 作者:行者123 更新时间:2023-12-03 18:34:36 24 4
gpt4 key购买 nike

我有一个自定义排序 TStringList ...

Items.CustomSort(@CompareWords);

...使用此比较功能:
function CompareWords(List: TStringList; Index1, Index2: Integer): Integer;
begin
Result := StrIComp(PWideChar(List[Index1]), PWideChar(List[Index2]));
end;

但是在注意到我的代码存在一些问题后,它希望列表按顺序排序 StrIComp诱导,我创建了这个小支票......
for i := 1 to Items.Count - 1 do
begin
Assert(StrIComp(PWideChar(Items[i-1]), PWideChar(Items[i])) <= 0);
end;

......它失败了。

为什么列表没有正确排序?

最佳答案

你可能有 Items.Sorted=True。

关于delphi - 为什么我的 TStringList 没有排序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1513428/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com