You can always collect()
the keys of the dict to get a vector into which you can index:
keys_as_vector = collect(keys(v))
keys_as_vector[2]
But this allocates a new array to hold the keys, so it may not be the most efficient approach possible.
However, if you’re always accessing the elements by index instead of by key, then perhaps a SortedDict
isn’t really the right data structure for your case? Would a vector of Pair
s or Tuple
s work instead?