I know that sort() is O(1) space since the sorting is in place. However, sorted() function returns a new list with sorted elements. Since sorted() returns a new array with sorted elements, does this mean that an algorithm that uses the sorted() function takes O(n) space to execute? Would sorted() be the same thing as creating an array and copying all elements, then running sort() on that new array?
for i in sorted(some_list):
// do something
sorted()
uses Timsort: https://en.wikipedia.org/wiki/Timsort, which has O(n) space complexity.