需要对多维数组的输出进行排序 [英] Need to sort output from a multidimensional array

查看:69
本文介绍了需要对多维数组的输出进行排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

vb.net2005.
我有profitMarginArray(29,3)< 29实际上是一个变量,但是我想在示例中输入一个数字>我需要的是检索以某种方式按形状或形式排列在3上的元素0和3.最大的问题是元素3不是唯一的,因此可能有5个具有相同值(例如56.34),因此出现了排序列表.
当前数组可能类似于
项目1,.34,.75、54.67
Item2,.32,.75、57.33
项目3,.29,.5、42
项目4,.34,.75、54.67

已排序的内容看起来像:

条款2,57.33
项目1,54.67
项目4,54.67
Item3,42

寻找一些想法,我会担心代码.
在此先感谢!!

vb.net 2005.
I have profitMarginArray(29,3) <29 is actually a variable, but figured I''d put in a number for the example> and what I need is to retreive elements 0 and 3 sorted on 3 in some way shape or form. The biggest problem is element 3 isn''t unique so there could be 5 that have the same value (56.34 for instance) so a sorted list is out.
The current array could look something like
Item1, .34, .75, 54.67
Item2, .32, .75, 57.33
Item3, .29, .5, 42
Item4, .34, .75, 54.67

The sorted what ever needs to look like:

Item2, 57.33
Item1, 54.67
Item4, 54.67
Item3, 42

Looking for some ideas, I''ll worry about the code.
Thanks in advance!!

推荐答案

如果使用集合,则可以在比较"方法中指定对集合进行排序的方式.您需要查找IComparable和Compare.
HTH
If you use a collection, you can specify in the "Compare" method how you want the collection sorted. You need to look up IComparable and Compare.
HTH


文章的底部[ ^ ]是关于以下内容的一些信息多维排序.它建议使用锯齿状的数组使排序成为可能.
如果您有兴趣,它也包含源代码.
At the bottom of this article[^] is some information about multidimensional sorting. It suggests using a jagged array to make the sorting possible.
It also has contains source code if your interested.


Array.Sort可以使用ICompare自定义比较功能.

查看此链接:对自定义类对象进行排序
Array.Sort can take a ICompare custom compare function.

Look at this link : Sorting Array of Custom Class objects


这篇关于需要对多维数组的输出进行排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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