public static Node merge(Node head1, Node head2) {
		Node head = null, result = null;
		if (head1 == null)
			return head2;
		if (head2 == null)
			return head1;

		while (head1 != null && head2 != null) {
			if (head1.value < head2.value) {
				if (result == null) {
					head = result = head1;
					head1 = head1.next;
				} else {
					result.next = head1;
					result = head1;
					head1 = head1.next;
				}
			} else {
				if (result == null) {
					head = result = head2;
					head2 = head2.next;
				} else {
					result.next = head2;
					result = head2;
					head2 = head2.next;
				}
			}
		}

		result.next = head1 != null ? head1 : head2;
		
		return head;
	}