Sort the indices while pretty-printing a trace

Fixes https://github.com/numenta/nupic/issues/1393.