package temp;
import java.io.*;
import java.util.Arrays;
import java.util.Comparator;
public class Test {
public static void main
(String[] args
) { String[][] records
= loadRecords
();
@Override
return o1[0].compareTo(o2[0]);
}
});
saveRecords("/home/b/Desktop/sortedByName.txt", records);
@Override
return o1[1].compareTo(o2[1]);
}
});
saveRecords("/home/b/Desktop/sortedByNumber.txt", records);
@Override
int c
= Integer.
compare(o1
[2].
length(), o2
[2].
length()); if (c == 0) {
c = o1[2].compareTo(o2[2]);
}
return c;
}
});
saveRecords("/home/b/Desktop/sortedByScore.txt", records);
}
static void saveRecords
(String filepath,
String[][] records
) { try {
for (String[] columns
: records
) { bw.write(columns[0] + " " + columns[1] + " " + columns[2]);
bw.newLine();
}
}
}
}
}
}
static String[][] loadRecords
() { try {
for (int i = 0; i < 20; i++) {
records[i] = br.readLine().split(" ");
}
return records;
}
}
}
}
}
}
cGFja2FnZSB0ZW1wOwoKaW1wb3J0IGphdmEuaW8uKjsKaW1wb3J0IGphdmEudXRpbC5BcnJheXM7CmltcG9ydCBqYXZhLnV0aWwuQ29tcGFyYXRvcjsKCnB1YmxpYyBjbGFzcyBUZXN0IHsKCiAgICBwdWJsaWMgc3RhdGljIHZvaWQgbWFpbihTdHJpbmdbXSBhcmdzKSB7CiAgICAgICAgU3RyaW5nW11bXSByZWNvcmRzID0gbG9hZFJlY29yZHMoKTsKCiAgICAgICAgQXJyYXlzLnNvcnQocmVjb3JkcywgbmV3IENvbXBhcmF0b3I8U3RyaW5nW10+KCkgewogICAgICAgICAgICBAT3ZlcnJpZGUKICAgICAgICAgICAgcHVibGljIGludCBjb21wYXJlKFN0cmluZ1tdIG8xLCBTdHJpbmdbXSBvMikgewogICAgICAgICAgICAgICAgcmV0dXJuIG8xWzBdLmNvbXBhcmVUbyhvMlswXSk7CiAgICAgICAgICAgIH0KICAgICAgICB9KTsKICAgICAgICBzYXZlUmVjb3JkcygiL2hvbWUvYi9EZXNrdG9wL3NvcnRlZEJ5TmFtZS50eHQiLCByZWNvcmRzKTsKCiAgICAgICAgQXJyYXlzLnNvcnQocmVjb3JkcywgbmV3IENvbXBhcmF0b3I8U3RyaW5nW10+KCkgewogICAgICAgICAgICBAT3ZlcnJpZGUKICAgICAgICAgICAgcHVibGljIGludCBjb21wYXJlKFN0cmluZ1tdIG8xLCBTdHJpbmdbXSBvMikgewogICAgICAgICAgICAgICAgcmV0dXJuIG8xWzFdLmNvbXBhcmVUbyhvMlsxXSk7CiAgICAgICAgICAgIH0KICAgICAgICB9KTsKICAgICAgICBzYXZlUmVjb3JkcygiL2hvbWUvYi9EZXNrdG9wL3NvcnRlZEJ5TnVtYmVyLnR4dCIsIHJlY29yZHMpOwoKICAgICAgICBBcnJheXMuc29ydChyZWNvcmRzLCBuZXcgQ29tcGFyYXRvcjxTdHJpbmdbXT4oKSB7CiAgICAgICAgICAgIEBPdmVycmlkZQogICAgICAgICAgICBwdWJsaWMgaW50IGNvbXBhcmUoU3RyaW5nW10gbzEsIFN0cmluZ1tdIG8yKSB7CiAgICAgICAgICAgICAgICBpbnQgYyA9IEludGVnZXIuY29tcGFyZShvMVsyXS5sZW5ndGgoKSwgbzJbMl0ubGVuZ3RoKCkpOwogICAgICAgICAgICAgICAgaWYgKGMgPT0gMCkgewogICAgICAgICAgICAgICAgICAgIGMgPSBvMVsyXS5jb21wYXJlVG8obzJbMl0pOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgcmV0dXJuIGM7CiAgICAgICAgICAgIH0KICAgICAgICB9KTsKICAgICAgICBzYXZlUmVjb3JkcygiL2hvbWUvYi9EZXNrdG9wL3NvcnRlZEJ5U2NvcmUudHh0IiwgcmVjb3Jkcyk7CiAgICB9CgogICAgc3RhdGljIHZvaWQgc2F2ZVJlY29yZHMoU3RyaW5nIGZpbGVwYXRoLCBTdHJpbmdbXVtdIHJlY29yZHMpIHsKICAgICAgICB0cnkgewogICAgICAgICAgICB0cnkgKEZpbGVPdXRwdXRTdHJlYW0gZm9zID0gbmV3IEZpbGVPdXRwdXRTdHJlYW0oZmlsZXBhdGgpKSB7CiAgICAgICAgICAgICAgICB0cnkgKE91dHB1dFN0cmVhbVdyaXRlciBvc3cgPSBuZXcgT3V0cHV0U3RyZWFtV3JpdGVyKGZvcykpIHsKICAgICAgICAgICAgICAgICAgICB0cnkgKEJ1ZmZlcmVkV3JpdGVyIGJ3ID0gbmV3IEJ1ZmZlcmVkV3JpdGVyKG9zdykpIHsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChTdHJpbmdbXSBjb2x1bW5zIDogcmVjb3JkcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgYncud3JpdGUoY29sdW1uc1swXSArICIgIiArIGNvbHVtbnNbMV0gKyAiICIgKyBjb2x1bW5zWzJdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJ3Lm5ld0xpbmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgIH0gY2F0Y2ggKElPRXhjZXB0aW9uIGUpIHsKICAgICAgICAgICAgdGhyb3cgbmV3IFJ1bnRpbWVFeGNlcHRpb24oZSk7CiAgICAgICAgfQogICAgfQoKICAgIHN0YXRpYyBTdHJpbmdbXVtdIGxvYWRSZWNvcmRzKCkgewogICAgICAgIHRyeSB7CiAgICAgICAgICAgIFN0cmluZ1tdW10gcmVjb3JkcyA9IG5ldyBTdHJpbmdbMjBdW107CiAgICAgICAgICAgIHRyeSAoRmlsZUlucHV0U3RyZWFtIGZpcyA9IG5ldyBGaWxlSW5wdXRTdHJlYW0oIi9ob21lL2IvRGVza3RvcC9kYXRhLnR4dCIpKSB7CiAgICAgICAgICAgICAgICB0cnkgKElucHV0U3RyZWFtUmVhZGVyIGlzciA9IG5ldyBJbnB1dFN0cmVhbVJlYWRlcihmaXMpKSB7CiAgICAgICAgICAgICAgICAgICAgdHJ5IChCdWZmZXJlZFJlYWRlciBiciA9IG5ldyBCdWZmZXJlZFJlYWRlcihpc3IpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoaW50IGkgPSAwOyBpIDwgMjA7IGkrKykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVjb3Jkc1tpXSA9IGJyLnJlYWRMaW5lKCkuc3BsaXQoIiAiKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcmVjb3JkczsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICB9IGNhdGNoIChJT0V4Y2VwdGlvbiBlKSB7CiAgICAgICAgICAgIHRocm93IG5ldyBSdW50aW1lRXhjZXB0aW9uKGUpOwogICAgICAgIH0KICAgIH0KfQo=