You are viewing a single comment's thread. Return to all comments →
The cleanest way to do this would be to define Node ordering using data.
Node
data
For example, this works:
def lt(self, other): return self.data < other.data Node.__lt__ = lt def MergeLists(A, B): if not A or not B: C = A or B else: C = min([A, B]) C.next = MergeLists(C.next, max([A, B])) return C
Seems like cookies are disabled on this browser, please enable them to open this website
Merge two sorted linked lists
You are viewing a single comment's thread. Return to all comments →
The cleanest way to do this would be to define
Node
ordering usingdata
.For example, this works: