在经典 ASP 中对集合进行排序 [英] Sorting a collection in classic ASP

查看:29
本文介绍了在经典 ASP 中对集合进行排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

It's quite a simple question - how do I sort a collection?

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

I've got a CSV file with rows in a random order. I'd like to sort the rows according to the date in one column. Do I add the rows to a recordset? Can I sort with a Scripting.Dictionary?

我显然已经被 .NET 和 Linq 宠坏了,现在我发现自己又回到了经典的 asp 领域,意识到我一定在 7 年前就知道这一点,并且非常想念泛型.我觉得自己像个完整的 n00b.

I've clearly been spoilt with .NET and Linq, and now I find myself back in the land of classic asp, realising I must have known this 7 years ago, and missing generics immensely. I feel like a complete n00b.

推荐答案

在这种情况下,我会得到.net大哥的帮助.可以在您的 ASP 应用程序中使用 System.Collections.Sortedlist 并让您的键值对排序.

In this case I would get help from big brother .net. It's possible to use System.Collections.Sortedlist within your ASP app and get your key value pairs sorted.

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 类也可用:

Btw if the following .net classes are available too:

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

另见:COM .NET 的奇迹互操作

这篇关于在经典 ASP 中对集合进行排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆