Windows Explorer sort method

前端 未结 8 1226
萌比男神i
萌比男神i 2020-12-11 00:33

I\'m looking for an algorithm that sorts strings similar to the way files (and folders) are sorted in Windows Explorer. It seems that numeric values in strings are taken int

相关标签:
8条回答
  • 2020-12-11 01:04

    Have a look at

    http://www.interact-sw.co.uk/iangblog/2007/12/13/natural-sorting

    for some source code.

    0 讨论(0)
  • This is a try to implement it in Java:

    Java - Sort Strings like Windows Explorer

    In short it splits the two Strings to compare in Letter - Digit Parts and compares this parts in a specific way to achieve this kind of sorting.

    0 讨论(0)
  • 2020-12-11 01:06

    It's called "natural sort order". Jeff had a pretty extensive blog entry on it a while ago, which describes the difficulties you might overlook and has links to several implementations.

    0 讨论(0)
  • 2020-12-11 01:06

    I also posted a related question with additional hints and pitfalls:

    Sorting strings is much harder than you thought

    0 讨论(0)
  • 2020-12-11 01:13

    There is StrCmpLogicalW, but it's only available starting with Windows XP and only implemented as Unicode.

    Some background information: http://www.siao2.com/2006/10/01/778990.aspx

    0 讨论(0)
  • 2020-12-11 01:19

    I posted code (C#) and a description of the algorithm here:

    Natural Sort Order in C#

    0 讨论(0)
提交回复
热议问题