Added comparator classes for sorting.