PriorityQueue pq = new PriorityQueue<>((a, b) -> {
if( Math.abs(a-x) < Math.abs(b-x) ) {
return 1;
}
else if(Math.abs(a-x) == Math.abs(b-x)) {
if(a == b)
return 1;
else if(a < b)
return 1;
else
return -1;
}
else {
return -1;
}
});
PriorityQueue pq = new PriorityQueue<>((a, b) -> {
if( Math.abs(a-x) < Math.abs(b-x) ) {
return 1;
}
else if(Math.abs(a-x) == Math.abs(b-x)) {
if(a == b)
return 1;
else if(a < b)
return 1;
else
return -1;
}
else {
return -1;
}
});