def insertionSortList_TLE(self, head):
        """
        Time Limit Exceded
        """
        comparator = lambda x, y: cmp(x.val, y.val)
        # open set & closed set
        dummy_head = ListNode(0)
        dummy_head.next = head


        closed_tail = dummy_head.next
        while(closed_tail and closed_tail.next):
            open_head = closed_tail.next
            # open_head_next = closed_tail.next.next

            # find position
            ptr_before = dummy_head
            ptr = dummy_head.next # error using ptr = head

            # WHILE OUTSIDE IF THUS INCREASING TIME COMPLEXITY
            while(ptr_before):
                if comparator(ptr, open_head)>0:
                    ptr_before.next = open_head
                    closed_tail.next = open_head.next
                    open_head.next = ptr

                    # closed_tail.next = open_head_next
                    break

                if ptr==open_head:
                    closed_tail = closed_tail.next
                    break

                ptr_before = ptr_before.next
                ptr = ptr.next


        return dummy_head.next
dataset/ETHPy150Open algorhythms/LeetCode/147 Insertion Sort List.py/Solution.insertionSortList_TLE/original