Wednesday, 15 February 2012

vb.net - Sorting an array (or list) -



vb.net - Sorting an array (or list) -

i have loop , in loop every time 3 different values, x, r, , c.

i want array (i have tried using list don't know how sort it, searched lot!) input 3 values @ each round of loop in new automatic index of array, , @ end want sort whole array based on ascending values (x, r, , c).

for illustration these values in array getting added (i don't need value array, these values (1,2,3) values, table)

storage(1,2,3) storage(2,3,4) storage(3,4,5) storage(4,5,6)

these 3 co-ordinates of positions of container in different stacks, , want find out 1 closer surface, , in closer stack. hence i'm adding them array, , sort them can find 1 closer (provided of these matches same type of container, located @ different places)

simply utilize .sort() method. utilize icomparable interface implemented each element of array. if dont specify custom comparer utilize default, ok integer values.

array:

dim inums() integer = new integer() {1, 11, 7, 5} array.sort(inums)

list:

dim aux new list(of integer)(new integer() {1, 11, 7, 5}) aux.sort()

and if need can define own comparer: http://msdn.microsoft.com/en-us/library/system.icomparable(v=vs.71).aspx

arrays vb.net sorting

No comments:

Post a Comment