Added sorted predicate for sorting