Implement the selectionSortArray method that returns the array after sorting it using selection sort logic.
The input contains an integer array nums and its length size. Your task is to return the array sorted in ascending order using the selection sort idea.
Selection sort repeatedly selects the smallest value from the unsorted part of the array and places it at the current position. For example, [5,2,9,1] becomes [1,2,5,9].
Divide the array into two parts: sorted and unsorted.
For each position, find the smallest element in the remaining unsorted part and swap it with the current position. After each pass, one more element is fixed in its correct sorted position.
Pseudocode:
function selectionSortArray(nums, size):
for i from 0 to size - 2:
minIndex = i
for j from i + 1 to size - 1:
if nums[j] < nums[minIndex]:
minIndex = j
swap nums[i] and nums[minIndex]
return nums