Sort the integer array nums in ascending order using insertion sort and return the result. Walk left-to-right; for each new element, slide it leftward past any larger neighbors into its correct slot.
Insertion sort is O(n²) worst case but O(n) on already-sorted input — the best-case behaviour makes it a great closer for nearly-sorted data.
1 ≤ nums.length ≤ 1000-10⁴ ≤ nums[i] ≤ 10⁴Treat nums[0..i-1] as the sorted prefix; insert nums[i] into it by shifting larger elements right.