Declare two variables, i likes the end pointer of sorted vector and j likes the scanning pointer.
Aims to find the smallest value (or biggest value), therefore, j starts from i to scan until the end of nums. Then, the smallest value is changed with the value of index i by calling swap(). It means adding the smallest value to the sorted vector. Next step, i moves to the next index and go back to the previous action until all values are sorted.
Time complexity:
Best Case:Ο(n2)
Worst Case:Ο(n2)
Average Case:Ο(n2)
P.S. Whatever the input is, there are two for-loop to run!