From 542b2da06e6eae42b7b6fb6950ddc65d5b1a6205 Mon Sep 17 00:00:00 2001 From: beurmuz Date: Mon, 25 Jul 2022 11:13:21 +0900 Subject: [PATCH] =?UTF-8?q?#21=2022.07.25=20>=20=EC=A0=95=EB=A0=AC=20>=20?= =?UTF-8?q?=EA=B5=AD=EC=98=81=EC=88=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/cote/README.md | 2 +- src/cote/sort/test_01.js | 53 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 src/cote/sort/test_01.js diff --git a/src/cote/README.md b/src/cote/README.md index 18b1f096..19ab746a 100644 --- a/src/cote/README.md +++ b/src/cote/README.md @@ -4,4 +4,4 @@ |1|[그리디](./greedy/)|[거스름돈](./greedy/greedy_ex.js)
[큰 수의 법칙](./greedy/greedy_01.js)
[숫자 카드 게임](./greedy/greedy_02.js)
[1이 될 때까지](./greedy/greedy_03.js)
-
[모험가 길드](./greedy/test_01.js)
[곱하기 혹은 더하기](./greedy/test_02.js)
[문자열 뒤집기](./greedy/test_03.js)
|22.07.14



-
22.07.16


|O
X
O
O
-
O
O
O
|X
[22.07.16](./greedy/replay_01.js)
X
X
-
O
X
X
| |2|[구현](./implementation/)|[상하좌우](./implementation/imple_ex01.js)
[시각](./implementation/imple_ex02.js)
[왕실의 나이트](./implementation/imple_01.js)
[게임 개발](./implementation/imple_02.js)
-
[럭키 스트레이트](./implementation/test_01.js)
[문자열 재정렬](./implementation/test_02.js)
|22.07.15



-
22.07.20
22.07.23
|△


X
-
O
O|[22.07.17](./implementation/../replay_01.js)
[22.07.18](./implementation/replay_02.js)
[22.07.19](./implementation//replay_03.js)
[22.07.19](./implementation/replay_04.js)
-
X
X| |3|[DFS, BFS](./dfs%2Cbfs/)|[DFS 예제](./dfs%2Cbfs/dfs_ex.js)
[BFS 예제](./dfs%2Cbfs/dfs_ex.js)
[음료수 얼려 먹기](./dfs%2Cbfs/dfs%2Cbfs_01.js)
[미로 탈출](./dfs%2Cbfs/dfs%2Cbfs_02.js)
-
응|22.07.15

22.07.21
22.07.22
-
응|O
O
X
X
-
응|O
O
O
O
-
ㅇ| -|4|[정렬](./sort/)|[위에서 아래로](./sort/sort_ex_01.js)
[성적이 낮은 순서로 학생 출력하기](./sort/sort_ex_02.js)
[두 배열의 원소 교체](./sort/sort_ex_03.js)|22.07.22
22.07.24

|O
O
O
|X
X
X
| \ No newline at end of file +|4|[정렬](./sort/)|[위에서 아래로](./sort/sort_ex_01.js)
[성적이 낮은 순서로 학생 출력하기](./sort/sort_ex_02.js)
[두 배열의 원소 교체](./sort/sort_ex_03.js)
-
[국영수](./sort/test_01.js)|22.07.22
22.07.24

-
22.07.25
|O
O
O
-
O|X
X
X
-
O| \ No newline at end of file diff --git a/src/cote/sort/test_01.js b/src/cote/sort/test_01.js new file mode 100644 index 00000000..ba4c4e8d --- /dev/null +++ b/src/cote/sort/test_01.js @@ -0,0 +1,53 @@ +'use strict'; + +function solution(N, arr) { + arr.sort((a, b) => { + if (a[1] < b[1]) return 1 + else if (a[1] > b[1]) return -1 + else { + if (a[2] > b[2]) return 1 + else if (a[2] < b[2]) return -1 + else { + if (a[3] < b[3]) return 1 + else if (a[3] > b[3]) return -1 + else { + if (a[0] > b[0]) return 1 + else if (a[0] < b[0]) return -1 + else return 0 + } + } + } + }); + + arr.forEach((student) => console.log(student[0])); +} + +const arr = [['Junkyu', 50, 60, 100], + ['SangKeun', 80, 60, 50], + ['Sunyoung', 80, 70, 100], + ['Soong', 50, 60, 90], + ['Haebin', 50, 60, 100], + ['Kangsoo', 60, 80, 100], + ['Donghyuk', 80, 60, 100], + ['Sei', 70, 70, 70], + ['Wonseon', 70, 70, 90], + ['Sanghyun', 70, 70, 80], + ['nsj', 80, 80, 80], + ['Taewhan', 50, 60, 90] +] +console.log(solution(12, arr)); + +// 다른 방법 +/* +arr.sort((a, b) => { + const aScore = (100-a[1])*10**6 + a[2]*10**3 + (100-a[3]); + const bScore = (100-b[1])*10**6 + b[2]*10**3 + (100-b[3]); + if (aScore === bScore) { + if (a[0] > b[0]) return 1 + else if (a[0] < b[0]) return -1 + else return 0 + } else { + return aScore - bScore; + } + }); +*/ \ No newline at end of file