added check for nan and added sorting to print_top_n_sentences