this is the scenario, i have 100 numbers (random). how do i get the highest 10 numbers from this set of numbers that i have.
Printable View
this is the scenario, i have 100 numbers (random). how do i get the highest 10 numbers from this set of numbers that i have.
Sort them, and then take the first 10.
you can sort them using SQL, assume these values are in an array
+Quote:
Originally posted by newace
you can sort them using SQL, assume these values are in an array
Is that an answer to yor question ? :p
i meant you "CANT", it was a typo
Load them INTO an array, and then sort them into a NEW ARRAY. Then you can take the LAST 10, as they will be the highest, assuming that you sorted them in ascending order. There is a Bubble Sort example in the codebank, although writing you own isn't too hard.
Look into the "Quicksort" sorting algorithm.
Or put a hidden Listbox on your form and set its Sorted property to True. Place the numbers in the listbox using Format(MyNumber, "0000000") (if your number can be bigger than 9999999 or it has decimals then use the appropriate format) so they will all have the same number of characters.