Notice
Recent Posts
Recent Comments
관리 메뉴

πŸŒ²μžλΌλ‚˜λŠ”μ²­λ…„

μžλ°”μ—μ„œ sort ν•˜κΈ° λ³Έλ¬Έ

μ•Œκ³ λ¦¬μ¦˜ λ¬Έμ œν’€μ΄

μžλ°”μ—μ„œ sort ν•˜κΈ°

JihyunLee 2019. 3. 19. 02:29
λ°˜μ‘ν˜•
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package ch5;
//κ΅­μ–΄ μ μˆ˜κ°€ κ°μ†Œν•˜λŠ” μˆœμ„œλ‘œ
 
//κ΅­μ–΄ μ μˆ˜κ°€ κ°™μœΌλ©΄ μ˜μ–΄ μ μˆ˜κ°€ μ¦κ°€ν•˜λŠ” μˆœμ„œλ‘œ
 
//κ΅­μ–΄ μ μˆ˜μ™€ μ˜μ–΄ μ μˆ˜κ°€ κ°™μœΌλ©΄ μˆ˜ν•™ μ μˆ˜κ°€ κ°μ†Œν•˜λŠ” μˆœμ„œλ‘œ
 
//λͺ¨λ“  μ μˆ˜κ°€ κ°™μœΌλ©΄ μ΄λ¦„이 μ‚¬μ „ μˆœμœΌλ‘œ μ¦κ°€ν•˜λŠ” μˆœμ„œλ‘œ (단, μ•„μŠ€ν‚€ μ½”λ“œμ—μ„œ λŒ€λ¬ΈμžλŠ” μ†Œλ¬Έμžλ³΄λ‹€ μž‘μœΌλ―€λ‘œ μ‚¬μ „μˆœμœΌλ‘œ μ•žμ— μ˜¨λ‹€.)
 
//이름 κ΅­μ–΄ μ˜μ–΄ μˆ˜ν•™μœΌλ‘œ λ°μ΄ν„°κ°€ λ“€μ–΄μ˜¨λ‹€.
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;
 
public class Q10825 {
 
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner scan = new Scanner(System.in);
        int num = scan.nextInt();
        String[][] arr = new String[num][4];
 
        for(int i=0;  i<num; i++) {
            arr[i][0]=scan.next();
            arr[i][1]=scan.next();
            arr[i][2]=scan.next();
            arr[i][3]=scan.next();
        }
 
        Arrays.sort(arr, new Comparator<String[]>() {
 
            @Override
            public int compare(String[]s1, String[] s2) {
                int k1 = Integer.parseInt(s1[1]);
                int k2 = Integer.parseInt(s2[1]);
                int e1 = Integer.parseInt(s1[2]);
                int e2 = Integer.parseInt(s2[2]);
                int m1 = Integer.parseInt(s1[3]);
                int m2 = Integer.parseInt(s2[3]);
 
                if(k1==k2) {
                    if(e1==e2) {
                        if(m1==m2) {
                            return s1[0].compareTo(s2[0]);//이름 μ‚¬μ „μˆœ
                        }else {
                            return Integer.compare(m2, m1);//μˆ˜ν•™ μ μˆ˜κ°€ κ°μ†Œν•˜λŠ” μˆœμ„œ
                        }
                    }else {
                        return Integer.compare(e1, e2);//μ˜μ—¬μ μˆ˜ μ¦κ°€ν•˜λŠ” μˆœ
                    }
                }else {
                    return Integer.compare(k2, k1);//κ΅­μ–΄  μ μˆ˜κ°€ κ°μ†Œν•˜λŠ” μˆœμ„œ
 
                }
            }
 
 
        });
        for(int i=0;  i<num; i++) {
            System.out.println(arr[i][0]);
        }
 
 
    }
 
}
 
cs


λ°˜μ‘ν˜•