Lambda expression is used set the priority , if frequencies are not equal than the string with greater frequency is returned else the string which is lexically smaller is returned
PriorityQueue < String > Order = new PriorityQueue < > ( ( a , b ) -> ( Freq . get ( a ) != Freq . get ( b ) ) ? Freq . get ( a ) - Freq . get ( b ) : b . compareTo ( a ) ) ;