[프로그래머스 | Lv. 1 | JavaScript] 문자열 내 마음대로 정렬하기
·
알고리즘/문제
Link코딩테스트 연습 - 문자열 내 마음대로 정렬하기 문제풀이(1)function solution(strings, n) { return strings.sort((a, b) => { if (a[n] !== b[n]) return a.charCodeAt(n) - b.charCodeAt(n) return a.localeCompare(b) });}(2)function solution(strings, n) { return strings.sort((a, b) => a[n] !== b[n] ? a[n].localeCompare(b[n]) : a.localeCompare(b));}