Open ategge opened 6 years ago
if you use a.sort() then the list will always be sorted throughout the rest of the code. If you use sorted(a) the code will be sorted for that next line, but you would have to continue to use the sorted(a) if you wanted to sort it again
I have a list and I want to sort it. However, online there are two sort functions:
a = [1,4,3,5,7,6,8]
sorted(a)
a.sort()
What are the differences between these two functions?