I have a dictionary with integer keys and integer items, and just need to sort the dictionary based on the key, but all examples I've found work only for string keys.
相关问题
- How to get the maximum of more than 2 numbers in V
- Faster loop: foreach vs some (performance of jsper
- Convert Array to custom object list c#
- Excel sunburst chart: Some labels missing
- pick a random item from a javascript array
相关文章
- Numpy matrix of coordinates
- PHP: Can an array have an array as a key in a key-
- Get column data by Column name and sheet name
- Accessing an array element when returning from a f
- How can I convert a PHP function's parameter l
- How to make a custom list deserializer in Gson?
- programmatically excel cells to be auto fit width
- Recursively replace keys in an array
edited to add a solution to output X and Y arrays
you could use
SortedList
object and build a helper sub like follows:to be exploited as follows:
for instance here's a test:
what above can be easily twicked to return
X
andY
arrays out of dictionarykeys
anditems
, as follows:to be exploited in your main sub as follows:
as you can see in this complete test:
Grab the keys as an array, sort that array, then use the sorted array to pull the values from the dictionary.
Output:
Code:
Results:
Here is a solution based on using the .Net container ArrayList -- which can be used in VBA. It takes much of the hassle out of sorting:
A simple test:
Output: