You can do this by reversing the lists. First of all, you reverse both lists and then compare both lists by traversing through them and then inserting the large value at the beginning of a new list, and hence you get a list with sorted elements. First, start an empty list with a head as NULL, assuming the heads of the given lists as H1 and H2, and reverse the lists. Now if the H1 becomes null before H2, you have to insert all the nodes of the list with the H2 head at the beginning of the new list. Otherwise, you do the same for the other list. This is how you can get the desired list with sorted elements.