You can't write a single comparator for everything without some assumptions on what the types will be. What do you do with custom classes? How can you decide which one is greater than the other? For more classes in the wild, a comparator does not make sense.
On the other hand, if you restrict yourself to String, Integer, Double, then they are Comparable and you can simply write the comparator with the compareTo() method:
public int compare(T element1,T element2)
{
return element1.compareTo(element2);
}
but then you would simply use the natural order of elements, and it would defeat the purpose of using a comparator. You usually don't need one in these cases.