public ListNode mergeTwoLists(ListNode l1, ListNode l2) {

        ListNode p1 = l1;
        ListNode p2 = l2;

        ListNode temp = new ListNode(0);
        ListNode p = temp;

        while (p1 != null && p2 != null) {
            if (p1.getVal() <= p2.getVal()) {
                p.setNext(p1);
                p1 = p1.getNext();
            } else {
                p.setNext(p2);
                p2 = p2.getNext();
            }
            p = p.getNext();
        }

        if (p1 != null) {
            p.setNext(p1);
        }
        if (p2 != null) {
            p.setNext(p2);
        }
        return temp.getNext();
    }