您可以将自定义传递Comparison给Array.Sort,所以只需在那里读取文件:
Array.Sort(str, Function(a, b)
Dim aContents As String = IO.File.ReadAllText(a)
Dim bContents As String = IO.File.ReadAllText(b)
'Compare the contents and return -1 if a < b, 0 if a = b, or 1 if a > b.
End Function)
Run Code Online (Sandbox Code Playgroud)
如果效率是一个问题,您可能希望将每个文件的内容缓存在一个Dictionary或类似的东西中.
此外,您可以使用LINQ,具体取决于您需要排序的文件中的确切内容:
Dim result = str.
Select(Function(x) New With {.File = x, .Contents = IO.File.ReadAllText(x)}).
OrderBy(Function(y) y.Contents)
Run Code Online (Sandbox Code Playgroud)
... 例如.
| 归档时间: |
|
| 查看次数: |
432 次 |
| 最近记录: |