Help for this page
cat test.txt | sed -e's/\(.*\) \(.*\)/\2,\1/g' | sort
$ sort +1 -2 +0 -1 <test.txt >output.txt