合并排序的思路

class Solution {
     public ListNode mergeTwoLists(ListNode l1, ListNode l2) {
        ListNode tem = new ListNode(0);
        ListNode ans = tem;
        while(l1!=null&&l2!=null){
            if(l1.val<l2.val){
                tem.next = l1;
                l1 = l1.next;
            }
            else{
                tem.next = l2;
                l2 = l2.next;
            }
            tem = tem.next;
        }
        if(l1!=null){tem.next = l1;}
        if(l2!=null){tem.next = l2;}
        return ans.next;
    }
}