how can we interchange indices and entries of a table?

for example,if we have a table T=table([aa=2, bb=3 cc=4, dd=5]),how can we get another table(2=aa,3=bb,4=cc,5=dd) ?

another question:
if we have table([aa=3,bb=5,cc=1,dd=3]),how can we output indices according to entries' ascending order?

thank you

Partial answer

Here's my suggestion for the first question:

S:=table(Equate([entries(T)],[indices(T)]));

You can probably construct the second answer using the sort command.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
}