首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

怎么对两行数据进行排序

2012-03-13 
如何对两行数据进行排序?比如:有这样的一组数据字符型整型变量电脑a配件b内存条c主机箱d显卡f现在已经用排

如何对两行数据进行排序?
比如:
有这样的一组数据
                              字符型                   整型变量
                              电脑                           a
                              配件                           b
                              内存条                       c
                              主机箱                       d
                              显卡                           f
现在已经用排序法把整型变量的数据从大到小排列好了,可是如何也把字符型根据整型变量从大到小排列呢?
如:
        第一位:...
        第二位:...
        .
        .

或者用什么方法最好咯/?

[解决办法]
如何也把字符型根据整型变量从大到小排列呢?

不明白意思


[解决办法]
int a[] = {...}

HashTable strHT = new HashTable()
strHT.add( "a ", "电脑 ")
strHT.add( "b ", "配件 ")
...

a排序后,
foreach(int i in a){
strHT.Items(i.ToString())
}
[解决办法]
Hashtable ht = new Hashtable();ht.Add( "2 ", "电脑 ");ht.Add( "1 ", "配件 ");ht.Add( "9 ", "内存条 ");ht.Add( "0 ", "机箱 ");ht.Add( "7 ", "显卡 ");ht.Add( "3 ", "声卡 ");System.Collections.ArrayList al = new ArrayList(ht);al.Sort(new A());object[] o = al.ToArray();for(int i=0;i <o.Length;i++){DictionaryEntry de =( DictionaryEntry )o[i];Response.Write(de.Key + ": "+ de.Value + " <BR> ");}


class A:IComparer{#region IComparer 成员public int Compare(object x, object y){// TODO: 添加 A.Compare 实现 DictionaryEntry d1 = (DictionaryEntry)x;DictionaryEntry d2 = (DictionaryEntry)y; return Convert.ToInt32(d1.Key) - Convert.ToInt32(d2.Key);}#endregion}

热点排行