这是一个非常简单的问题 - 如何对集合进行排序?
我有一个 CSV 文件,其中的行顺序是随机的。我想根据一列中的日期对行进行排序。我是否将行添加到记录集中?我可以使用 Scripting.Dictionary 进行排序吗?
我显然已经被 .NET 和 Linq 宠坏了,现在我发现自己又回到了经典 asp 的土地,意识到我肯定在 7 年前就知道了这一点,并且非常怀念泛型。我感觉自己像个十足的n00b。
最佳答案
在这种情况下,我会从老大哥.net那里得到帮助。可以在 ASP 应用程序中使用 System.Collections.Sortedlist 并对键值对进行排序。
set list = server.createObject("System.Collections.Sortedlist")
with list
.add "something", "YY"
.add "something else", "XX"
end with
for i = 0 to list.count - 1
response.write(list.getKey(i) & " = " & list.getByIndex(i))
next
顺便说一句,如果以下 .net 类也可用:
- 系统.集合.队列
- 系统.Collections.Stack
- System.Collections.ArrayList
- System.Collections.SortedList
- System.Collections.Hashtable
- System.IO.StringWriter
- 系统.IO.MemoryStream;
关于在经典 ASP 中对集合进行排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/156436/