Why is the ouput not showing 20,1 pair

thats because your comparator function is incomplete please add what it should return in case p1.second == p2.second and it’ll show 20, 1 in the output as well.