function ListNode(x){
this.val = x;
this.next = null;
}
function mergeKLists( lists ) {
// write code here
var arr=[]
for(var i=0;i<lists.length;i++){
var cur=lists[i]
while(cur){
arr.push(cur.val);
cur=cur.next;
}
}
arr.sort((a,b)=>a-b);
var dummy=new ListNode(-1)
var temp=dummy;
for(var i=0;i<arr.length;i++){
temp.next=new ListNode(arr[i])
temp=temp.next;
}
return dummy.next;
}
this.val = x;
this.next = null;
}
function mergeKLists( lists ) {
// write code here
var arr=[]
for(var i=0;i<lists.length;i++){
var cur=lists[i]
while(cur){
arr.push(cur.val);
cur=cur.next;
}
}
arr.sort((a,b)=>a-b);
var dummy=new ListNode(-1)
var temp=dummy;
for(var i=0;i<arr.length;i++){
temp.next=new ListNode(arr[i])
temp=temp.next;
}
return dummy.next;
}