fixed a bug of getSortedSentences()

There's a bug which makes wrong sorted sentences at getSortedSentences() function. Fixed.