Skip to content

Commit

Permalink
#7 22.03.04 > 7번문제 풀기
Browse files Browse the repository at this point in the history
  • Loading branch information
beurmuz committed Mar 4, 2022
1 parent b1d9b9f commit 7e9b1d5
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/inf/sort,greedy/7.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<html>
<head>
<meta charset="UTF-8">
<title>출력결과</title>
</head>
<body>
<script>
function solution(arr){
let answer=arr;
answer.sort((a,b) => {
if(a[0]===b[0]) {
return a[1]-b[1]; //y값에 대해 오름차순 정렬
} else {
return a[0]-b[0];
}
});
return answer;
}

let arr=[[2, 7], [1, 3], [1, 2], [2, 5], [3, 6]];
console.log(solution(arr));
</script>
</body>
</html>

0 comments on commit 7e9b1d5

Please sign in to comment.