考虑这段代码:
var files = Directory.GetFiles(filePath);
var dataFiles = from file in files
where System.IO.Path.GetExtension(file) == extension
orderby file.Length
select file;
我一直在寻找可以进行“自然排序”的字符串比较器。遗憾的是,这个常见任务没有内置功能。我找到了这篇文章,看起来不错。
我可以将 NaturalStringComparer 与LINQ 查询语法一起使用吗?我知道使用 lambdas 的解决方案。