sort로 문자열 정렬하는 연습 문제다.
이 두 조건만 만족하도록 sort하면 된다.
function solution(strings, n) { strings.sort((a, b) => { if (a[n] === b[n]) { return a > b ? 1 : -1; } else { return a[n] > b[n] ? 1 : -1; } }); return strings; }
출처: 프로그래머스