在经典ASP中对集合进行排序

har*_*ott 7 sorting asp-classic

这是一个非常简单的问题 - 如何对集合进行排序?

我有一个CSV文件,其中包含随机顺序的行.我想根据一列中的日期对行进行排序.我是否将行添加到记录集?我可以使用Scripting.Dictionary进行排序吗?

我显然已经被.NET和Linq宠坏了,现在我发现自己回到了经典asp的领域,意识到我必须在7年前就知道这一点,并且非常遗漏了仿制品.我觉得这是一个完整的n00b.

Mic*_*hal 14

在这种情况下,我会得到大哥.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
Run Code Online (Sandbox Code Playgroud)

顺便说一下,如果以下.net类也可用:

  • System.Collections.Queue
  • System.Collections.Stack
  • System.Collections.ArrayList
  • System.Collections.SortedList
  • System.Collections.Hashtable
  • System.IO.StringWriter
  • System.IO.MemoryStream;

另请参阅:COM .NET互操作的奇迹