How would you sort an array without using an inbuilt function?
Implement sort_array(nums) to return the elements in ascending order without calling Python's sorting functions or other built-in sorting utilities. The input is a list of integers, and the function should return a new sorted list without modifying the original.
Input: nums, a list of integers. Output: a list containing the same values in ascending order.
Examples:
[5, 2, 8, 1] returns [1, 2, 5, 8].[3, 3, -1, 0] returns [-1, 0, 3, 3].Constraints: 0 <= len(nums) <= 5,000; values are between -10^9 and 10^9.
def sort_array(nums):