I'm basically trying to put Linked list nodes into a priority queue. Here ListNode is my LinkedList class and lists is a python list that contains heads of different linked lists. I've no idea why I'm getting the following error message.
TypeError: '<' not supported between instances of 'ListNode' and 'ListNode'
Q = PriorityQueue()
for node in lists:
if node:
Q.put((node.val,node))
LinkedList class:
class ListNode:
def __init__(self, val=0, next=None):
self.val = val
self.next = next