Explain how you would sort an array and what memory allocation considerations you would take into account.
Implement an in-place ascending sort that returns the same list object after modification. Prefer an approach with predictable O(n log n) time and O(1) auxiliary space; explain how your choice compares with allocation-heavy alternatives.
Function: def sort_array(nums):. Input and output are lists of integers.
def sort_array(nums):