How to turn a list inside out? Languages

How to turn a list inside out?

I've got a following list:So we can say that 3 belongs to group 1, 6 belongs to group 2, 7 belongs to group 3 and so on. I need a reverse mapping, i.e. to every number I want to have a group id that it belongs to (see expected output):
Read More