Created
          December 30, 2019 15:59 
        
      - 
      
- 
        Save dalcon10028/f421e396623744af9d5ccdce17a2bc7e to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import java.util.*; | |
| public class Main { | |
| public static void main(String[] args) { | |
| Scanner sc = new Scanner(System.in); | |
| StringBuilder sb = new StringBuilder(); // 출력이 많으므로 사용합니다. | |
| int N = sc.nextInt(); | |
| int [][]pos = new int[N][2]; | |
| for(int i=0; i<N; i++){ | |
| pos[i][0] = sc.nextInt(); // x 좌표 | |
| pos[i][1] = sc.nextInt(); // y 좌표 | |
| } | |
| sc.close(); | |
| Arrays.sort(pos, new Comparator<int[]>(){ | |
| @Override | |
| public int compare(int[] a, int[] b) { | |
| if(a[1] != b[1]) | |
| return a[1] - b[1]; // y좌표가 다르면 y 비교 | |
| return a[0] - b[0]; // 아니면 x비교 | |
| } | |
| }); | |
| for (int[] is : pos) | |
| sb.append(is[0] + " " + is[1] + "\n"); | |
| System.out.print(sb); | |
| } | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment