Added comparator for sorting terms on their frequency.