File descriptors odd question
I'm reading a book on some interesting linux hacks and came across one that I'm slightly stumped on. I know about file descriptors 0, 1, and 2 (input, output, error) and how you can direct them to go down the same stream like so: command 2>&1 | ..... or var=`command 2>$1` but where I'm getting a bit confused is when they swap the descriptors using the mostly unused 3-9 FDs like so:
command 3>&2 2>&1 1>&3 | ....
Why would I want to swap file descriptors in the first place? Any practical examples? Also it mentions closing the extraneous FDs like so: 3>&~ , is this the correct format? doesn't ~ stand for the home directory? If anyone can shed some light on this I'd appreciate it.