with compare function for priority and tested for all data types