I want to define a recursive function can sort any list of ints:
def sort_l(l):
if l==[]:
return []
else:
if len(l)==1:
retur
For this you would want to use merge sort. Essentially in a merge sort you recursively split the list in half until you have single elements and than build it back up in the correct order. merge sort on has a complexity of O(n log(n))
and is an extremely stable sorting method.
Here are some good in depth explanations and visuals for merge sorting: