Created
          December 31, 2019 11:26 
        
      - 
      
- 
        Save dalcon10028/c6592d37566ebeac5d9ec7de71058b31 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(); | |
| String [][]member = new String[N][2]; | |
| for(int i=0; i<N; i++){ | |
| member[i][0] = sc.next(); // 나이 | |
| member[i][1] = sc.next(); // 이름 | |
| } | |
| sc.close(); | |
| Arrays.sort(member, new Comparator<String[]>() { | |
| @Override | |
| public int compare(String[] a, String[] b){ | |
| return Integer.parseInt(a[0])-Integer.parseInt(b[0]); // 나이만 비교합니다. | |
| } | |
| }); | |
| for (String[] strings : member) | |
| sb.append(strings[0] + " " + strings[1]+"\n"); | |
| System.out.print(sb); | |
| } | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment