adding sort on groups