nums
를 오름차 순 정렬function minimumDifference(nums: number[], k: number): number {
if(k === 1) return 0
let minGap = Infinity
const sorted = nums.toSorted((a, b) => a - b)
for(let i = 0; i <= sorted.length - k; i++) {
const min = sorted[i]
const max = sorted[i + k - 1]
const curGap = max - min
minGap = Math.min(minGap, curGap)
}
return minGap
};