function solution(array, commands) {
var answer = [];
for(const command of commands) {
var sArray=array.slice(command[0]-1,command[1])
sArray.sort((a,b)=>{return a-b})
answer.push(sArray[command[2]-1])
}
return answer;
}
sort안에 comparefunction을 정해주지않으면 실패가 나온다.