class Solution:
def mergeKLists(self, lists: List[ListNode]) -> ListNode:
heap = []
for each in lists: #遍历所有值加入堆中
while each:
heapq.heappush(heap, each.val)
each = each.next
head = ne = ListNode()
while heap: #遍历堆中值加入到listnode里
t = ListNode(heapq.heappop(heap))
ne.next = t
ne = ne.next
return head.next