arrays - VB.NET Get Keys by sorted Values in Hashtable -


i studying vb.net , want know better idea keys sorted values in hashtable

here solution built

  dim int_value integer() = new integer() {-9, 2, 8, 6, 8, 1, -9}         dim int_key integer() = new integer() {1, 2, 3, 4, 5, 6, 7}         dim dum_int(int_key.length) integer          dim store_keys new arraylist         array.copy(int_value, dum_int, dum_int.length - 1)         array.sort(dum_int)         array.reverse(dum_int)          = 0 dum_int.length - 1             ii = 0 int_value.length - 1                 if dum_int(i) = int_value(ii)                     store_keys.add(int_key(ii))                     int_value(ii) = integer.maxvalue                 end if             next         next 

i got output like..

'' output''

  • (0) 3 {integer} object
  • (1) 5 {integer} object
  • (2) 4 {integer} object
  • (3) 2 {integer} object
  • (4) 6 {integer} object
  • (5) 1 {integer} object
  • (6) 7 {integer} object

i assume have hashtable.

i create 2 arrays , store both keys (int_key) , values(int_value) hashtable

then copy value(int_value) array dum_int sort values

whenever found matching int value between sorted array , original value array

i stored in store_keys(arraylist) , insert max int value original array prevent overlapping issue.

however, there way improve method ?

i don't believe better sorting algor can't simplify method.

can provide hints simplify method?

thanks

the array.sort method has overload sort array based on array:

dim keys = myhastable.keys.cast(of integer)().toarray() dim values = myhastable.values.cast(of integer)().toarray()  array.sort(values, keys) 

Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo