加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

如何在Windows资源管理器中获得Delphi中的排序顺序?

发布时间:2020-12-13 21:01:27 所属栏目:Windows 来源:网络整理
导读:综述: 我所说的术语 寻找似乎是“自然的” 分类”。 对于操作系统中的行为: 对于Windows(版本 = XP),Windows资源管理器利用自然 分类。 对于Linux终端:使用“ls -v”而不是纯粹的“ls”来获取自然 分类。 对于在Delphi中进行编程,使用StrCmpLogicalW Wi
综述:

>我所说的术语
寻找似乎是“自然的”
分类”。
>对于操作系统中的行为:

>对于Windows(版本> = XP),Windows资源管理器利用自然
分类。
>对于Linux终端:使用“ls -v”而不是纯粹的“ls”来获取自然
分类。

>对于在Delphi中进行编程,使用StrCmpLogicalW Windows API来进行自然排序。
>用于Delphi& Kylix&拉撒路,用手工制作的功能
自然分类:

>(1)由Martin Pool自然排序字符串比较的Delphi包装器。
http://irsoft.de/web/strnatcmp-and-natsort-for-delphi
>(2)来自davekeolle网站的其他语言的字母排序算法代码。
http://www.davekoelle.com/alphanum.html
>(3)其他知识网页:
http://www.codinghorror.com/blog/2007/12/sorting-for-humans-natural-sort-order.html
http://objectmix.com/delphi/722211-natural-sorting-optimizing-working-solution.html
http://groups.google.com/group/borland.public.delphi.language.delphi.general/browse_thread/thread/1141d49f8bbba577
http://objectmix.com/delphi/401713-alphanumeric-sort-routine-delphi.html

==========================

以下文件名将在Windows资源管理器中订购,如下所示:

test_1_test.txt

test_2_test.txt

test_11_test.txt

test_12_test.txt

test_21_test.txt

test_22_test.txt

例如,如果我把它们放在TStringList实例中并调用Sort,排序顺序如下:

test_1_test.txt

test_11_test.txt

test_12_test.txt

test_2_test.txt

test_21_test.txt

test_22_test.txt

为了记录,上述文件名将在Cygwin的rxvt终端或Linux发行版的xterm终端(如CentOS)中进行订购,如下所示:

test_11_test.txt

test_12_test.txt

test_1_test.txt

test_21_test.txt

test_22_test.txt

test_2_test.txt

你能帮助评论如何理解这种排序行为的差异?此外,是否可以获得与Windows资源管理器中相同的顺序?任何建议是赞赏!

PS:我的Windows语言环境设置为中文,但我认为英文语言环境也是如此。

StrCmpLogicalW能处理数字,另一种是 CompareString

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读