Can you implement a sorting algorithm for a list from scratch?
Implement sort_list(nums) to return the numbers in nondecreasing order without using sorted() or .sort(). The function must return a new list and leave the input list unchanged. Any comparison-based sorting algorithm is acceptable, but explain its time and space complexity.
def sort_list(nums):