What is a linked list and what is its advantage over arrays? Write code to sort a linked list.
Asked in the Technical interview 1 stage. Candidate attempted merge sort.
Use a singly linked list whose nodes contain value and next. Implement sort_linked_list(head), returning the head of the same list after sorting values in nondecreasing order. In test cases, linked lists are represented as arrays of values for serialization.
def sort_linked_list(head):