Originally Posted by
Shaggy Hiker
Well, Sort does seem like a good approach, but it doesn't deal with matches the way you show you want to. What you might do is to start out with the Array.Sort method to get them into an order from highest to lowest, then take a second pass through the array giving them rank ordinals. The bigger question is where to put those.
What comes to mind at first would be to create a Dictionary(of X, Integer) where the Integer is the ordinal, but what should the X be? One option would be to make it Double, and have a value in there, except that won't work because you can't have duplicate keys. Another option would be to have a List(of List(of Double)) so that item 0 in the outer list is the rank, while the inner list held all the values. That's pretty silly, though, because there isn't much point in having a list holding 10.95, 10.95.
Yet another option would be a Dictionary(of Integer,Decimal) where the keys would be the ranks 5, 4, 3, 2, 1, and the values would be the numbers. You might not have values for all ranks, just as you don't have a 3 in your example, but that wouldn't be too bad. It's also a bit silly, though, unless all you really want is the number.
What might be a better option is to put the rank number into the .Tag of the Textbox. For this, you'd put the values in an array, sort them, then iterate through the array. The highest value gets a 5, if the next value is the same as the first, then it also gets a 5, otherwise the rank gets decremented and the next value gets that new rank. Putting those back into the .Tag property of the textboxes wouldn't be difficult, though it all depends on whether you need to retain which textbox had the rank, or if you just needed to know which value had the rank.