Comparator based on different fields of an object

I have an Employee object which contains two fields name and jobTitle
for sorting the Employee objects first priority should be on jobTitle, if jobTitle is null then the sorting should be based on name

If either of the titles is null, then the two Employees will evaluate as equals, even if one of them is not null. That's not what you want. You want all null titles to be equal to each other, but not non-null values.