Adding list rank numbers to output; correcting alphabetical sort bug