Implement the kthSmallestValue method that returns the kth smallest value from the array.
The input contains an integer array nums, its length size, and an integer k. Your task is to return the kth smallest value in the array.
The value of k is 1-based. That means k = 1 returns the smallest value, k = 2 returns the second smallest value, and so on. Duplicate values are counted as separate positions.
The simple way is to sort the array in ascending order.
After sorting, the smallest value is at index 0. Since k is 1-based, the kth smallest value is at index k - 1.
Pseudocode:
function kthSmallestValue(nums, size, k):
sort nums in ascending order
return nums[k - 1]