2 of 3 deleted 44 characters in body

GNU Make, 214 213 208 bytes

P=$(eval N=$(word $1,$X))$(if $N,$(if $(shell echo $N\>$M|bc|grep 1),$(eval M=$N),)$(eval A$N+=$1$(call $0,$(shell expr $1 + 1))),)
$(call P,1)$(foreach K,$(shell seq $M),$(info $(A$K)))

I/O: input array via arguments, output one per line, separated by spaces.

$ make -f swap.mk 2 2 2

3 2 1
make: *** No rule to make target `2'.  Stop.


X=$(MAKECMDGOALS)     # Input array
M=0                   # Max value encountered in X
    N=$(word $1,$X))  # Get next word from X
  $(if $N,$(if $(shell echo $N\>$M|bc|grep 1),
    $(eval M=$N),)    # Update M
    $(eval A$N+=$1    # Append index to a variable named after value
      $(call $0,      # Recurse (call returns empty string)
        $(shell expr $1 + 1))),)
$(call P,1)           # Initial call to P. 1 is the first index
$(foreach K,          # Print all values of A* variables
  $(shell seq $M),
  $(info $(A$K)))     # Uninitialized ones default to empty strings

The order of indices in sets is reversed because P calls itself recursively before updating A$2 (call executed in the evaluation of the right-hand side).