~51일차~
let fs = require('fs');
let input = fs.readFileSync('/dev/stdin').toString().split('\n')
let n = Number(input[0]);
let list = {};
let arr = [];
for(let i = 1; i <=n, i++) {
list.x = input[1].split(' ').map(Number);
list.y = input[2].split(' ').map(Number);
arr.push({...list});
}
function compare(a, b) {
if (a.x > b.x ) return -1;
else if (a.x < b.x ) return 1;
else return 0;
}
arr.sort(compare);
console.log(arr);
let fs = require('fs');
let input = fs.readFileSync('/dev/stdin').toString().split('\n')
let n = Number(input[0]);
let data = [];
for for(let i = 1; i <=n, i++) {
let [x, y] = input[i].split(' ').map(Number);
data.push([x,y]);
}
function compare (a, b) {
if (a[0] != b[0]) return a[0] - b[0];
else return a[1] - b[1];
}
data.sort(compare);
let answer = "";
for (let point of data) {
answer += point[0] + " " + point[1] + "\n";
}
console.log(anwser);
let fs = require('fs');
let input = fs.readFileSync('/dev/stdin').toString().split('\n')
let n = Number(input[0]);
let data = [];
for for(let i = 1; i <=n, i++) {
let [x, y] = input[i].split(' ').map(Number);
data.push([x,y]);
}
// 이부분만 1번 문제와 상이
function compare (a, b) {
if (a[1] != b[1]) return a[1] - b[1];
else return a[0] - b[0];
}
data.sort(compare);
let answer = "";
for (let point of data) {
answer += point[0] + " " + point[1] + "\n";
}
console.log(anwser);
let fs = require('fs');
let input = fs.readFileSync('/dev/stdin').toString().split('\n')
let n = Number(input[0]);
let arr = input[1].split(' ');
arr.sort(function (a,b) {
if (a.length != b.length) return a.length - b.length;
else if (a.length = b.length) {
if (a = b) return a;
else return a-b;
}
});
let answer = "";
for (let i = 0; i < arr.length; i++) {
answer += arr[i] + " ";
}
console.log(answer);
let fs = require('fs');
let input = fs.readFileSync('/dev/stdin').toString().split('\n')
let n = Number(input[0]);
let arr = [];
for (let i = 1; i <=n; i++) {
arr.push(input[i]);
}
//중복된 원소 먼저 제거 -> 집합(set)으로 변환한 뒤 배열로 되돌리기
arr = [...new Set(arr)];
arr.sort(function (a,b) {
if (a.length != b.length) return a.length - b.length;
else {
if (a < b) return -1;
else of (a > b) return 1;
else return 0;
}
});
for (let x of arr) {
console.log(x);
}