I have an Arraylist of objects - but I want to attach to each object a number (in this case distance of type int). This will be useful for me to sort on the distance value, the shortest to the longest and then do other operations.
eg.
OBJECT | INDEX | DISTANCE
-------------------------------
fooOject [0] 100
fooOject [1] 1465
fooOject [2] 8787
fooOject [3] 21
fooOject [4] 66....etc
Does anyone know how to do this, bearing in mind Im a bit of C# newbie...
Binu SubiPosted Feb 16, 2006, 10:24 AM
have a class like
class myclass {
int sortkey;
string myVal;
}
now your array list will have instances of this class ( you create a new instance, set the values and put it into your arraylist)
once you have this, you write your own sort() mthod that uses sortkey member in your class and sort based on that....
too much? what you think ;-)
Cheers!