ListNode *mergeTwoLists(ListNode *l1, ListNode *l2) {
if (l1 == NULL) return l2;
if (l2 == NULL) return l1;
ListNode *small, *big, *next, *head;
if (l1>val < l2>val) { small = l1; big = l2; }
else { small = l2; big = l1; }
head = small;
while (small != NULL && big != NULL) {
if (small>next == NULL  small>next>val > big>val) {
next = small>next;
small>next = big;
small = big;
big = next;
} else {
small = small>next;
}
}
return head;
}
This is my solution


Refined code:
class Solution { public: ListNode *mergeTwoLists(ListNode *l1, ListNode *l2) { ListNode *aux = new ListNode(0); ListNode *tmp = aux; while(l2) { if (l1 == NULL) { l1 = l2; break; } else if(l1>val < l2>val) { tmp = tmp>next = l1; l1 = l1>next; } else { tmp = tmp>next= l2; l2 = l2>next; } } tmp>next = l1; tmp = aux>next; delete aux; return tmp; } };