Class that compares the value pointed by node and make LinkedList sorted
class pairComp implements Comparator < pair > { public int compare ( pair p1 , pair p2 ) { return p1 . val - p2 . val ; } } class GFG {