Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 81ef077

Browse files
Add 문자열-내-마음대로-정렬하기.js
1 parent bba3ac3 commit 81ef077

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

‎level-1/문자열-내-마음대로-정렬하기.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,16 @@ function solution(strings, n) {
2222
else return a > b ? 1 : -1;
2323
});
2424
}
25+
26+
// 정답 3 - prove-ability
27+
function solution(strings, n) {
28+
// 정렬
29+
strings.sort((a, b) => {
30+
// n번째 클자가 같다면 사전순
31+
if(a[n].charCodeAt() === b[n].charCodeAt()) {
32+
return a > b ? 1 : -1;
33+
} else return a[n].charCodeAt() - b[n].charCodeAt();
34+
});
35+
36+
return strings;
37+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /