The index is now sorted at the end, and minor change to printout.