function solution(files) {
const answer = [];
const reg = /(\d+)/g;
for (let i = 0; i < files.length; i++) {
answer.push({ index: i, value: files[i].split(reg) });
}
answer.sort((a,b) => {
if((a.value[0].toLowerCase() < b.value[0].toLowerCase())) {
return -1;
} else if ((a.value[0].toLowerCase() > b.value[0].toLowerCase())) {
return 1;
} else {
if(parseInt(a.value[1]) < parseInt(b.value[1])) {
return -1
} else if(parseInt(a.value[1]) > parseInt(b.value[1])) {
return 1;
} else {
if(a.index < b.index) return -1;
else return 1;
}
}
})
return answer.map(item => item.value.join(""))
}