def sortList_array(self, head):
        if head==None:
            return None
        lst = [] # must be constant space
        current = head
        while(current):
            lst.append(current)
            current = current.next


        comparator = lambda x, y: cmp(x.val, y.val)
        lst = sorted(lst, comparator)  # return # sorted is not side-effect # O(n log n)
        for i in range(len(lst)-1):
            lst[i].next = lst[i+1]
        lst[-1].next = None
        return lst[0]
Workaround by sorted()
dataset/ETHPy150Open algorhythms/LeetCode/148 Sort List.py/Solution.sortList_array