import java.util.*;
class Solution {
public String[] solution(String[] files) {
String[] answer = new String[files.length];
String[][] file = new String[files.length][3];
for(int i=0; i<files.length; i++) {
int index = 0;
int state = 0;
for(int j=0; j<files[i].length(); j++) {
char c = files[i].charAt(j);
if(state==0 && c>='0' && c<='9') {
file[i][0] = files[i].substring(0, j);
index = j;
state = 1;
}
if(state==1 && !(c>='0'&&c<='9')) {
file[i][1] = files[i].substring(index, j);
file[i][2] = files[i].substring(j, files[i].length());
state = 2;
}
}
if(state == 1) {
file[i][1] = files[i].substring(index, files[i].length());
file[i][2] = "";
}
}
Arrays.sort(file, new Comparator<String[]>(){
@Override
public int compare(String[] s1, String[] s2) {
String ss1 = s1[0].toUpperCase();
String ss2 = s2[0].toUpperCase();
if(ss1.equals(ss2)) { return Integer.parseInt(s1[1])-Integer.parseInt(s2[1]); }
return ss1.compareTo(ss2);
}
});
for(int i=0; i<answer.length; i++) { answer[i] = file[i][0]+file[i][1]+file[i][2]; }
return answer;
}
}