递归实现:

public class Solution {
    public ListNode Merge(ListNode list1,ListNode list2) {
        if(list1==null&&list2==null) return null;
        if(list1==null&&list2!=null) return list2;
        if(list1!=null&&list2==null) return list1;

        if(list1.val>=list2.val){
            ListNode newHead = Merge(list1,list2.next);
            list2.next = newHead;
            return list2;
        }else{
            ListNode newHead = Merge(list1.next,list2);
            list1.next = newHead;
            return list1;
        }
    }
}