https://school.programmers.co.kr/learn/courses/30/lessons/17686
function solution(files) {
const reg = /^([a-zA-Z-\. ]+)([0-9]+)(.*)$/
let arr = [];
files.map((file, idx) => {
const [all, str, num] = file.match(reg);
arr.push({all, str: str.toLowerCase(), num: parseInt(num), idx})
})
return arr.sort((a,b) => {
if (a.str > b.str) return 1
if (a.str < b.str) return -1
if (a.num > b.num) return 1
if (a.num < b.num) return -1
return a.idx -b.idx;
}).map((v) => v.all)
}