When people speak - informally - about "sorting of dictionaries (assoc.arrays)", in
my experience we tend to mean accessing/enumerating the dictionary in particular order - either by order of keys or order of values.
Now, roAA have
.keys() method that returns array of the keys, pre-sorted.
OTOH, there is no
.values() method...
PS. I thought i'll illustrate,
'for keys'
for each key in myAA.keys(): 'already sorted, haha!'
do_the_due(key, myAA[key])
next
'for values - invert the dictionary'
inv_aa = {}
for each key in myAA:
val = myAA[key]
bucket = inv_aa[val]: if bucket=invalid then bucket = []: inv_aa[val] = bucket
bucket.push(key)
next
for each vals in inv_aa:
for each val in vals:
do_the_due(vals[val], val)
next
next