Click here to Skip to main content
15,891,981 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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!!
Posted
Comments
MacRaider4 23-Sep-11 11:42am    
Thanks Guys!!!

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
 
Share this answer
 
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.
 
Share this answer
 
Array.Sort can take a ICompare custom compare function.

Look at this link : Sorting Array of Custom Class objects
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900