第二题:排序 从文件中读入输入,排序后输出到另一个文件中,具体排序方式请分析输入和输出文件的内容确定,其中输入文件内容为
M.John
B.Kyle
C.Tom
----------
M.John
C.Thomsom
D.Harry
B.Sim
----------
A.Sarry
Y.Jim
----------
S.Sarry
Z.Zoo
----------
M.John
B.Sim
K.King
J.Jimmy
要求排序后输出为
A.Sarry
Y.Jim
----------
M.John
B.Kyle
C.Tom
----------
M.John
B.Sim
C.Thomsom
D.Harry
----------
M.John
B.Sim
J.Jimmy
K.King
----------
S.Sarry
Z.Zoo
----------
Done!!!!
M.John
B.Kyle
C.Tom
----------
M.John
C.Thomsom
D.Harry
B.Sim
----------
A.Sarry
Y.Jim
----------
S.Sarry
Z.Zoo
----------
M.John
B.Sim
K.King
J.Jimmy
要求排序后输出为
A.Sarry
Y.Jim
----------
M.John
B.Kyle
C.Tom
----------
M.John
B.Sim
C.Thomsom
D.Harry
----------
M.John
B.Sim
J.Jimmy
K.King
----------
S.Sarry
Z.Zoo
----------
Done!!!!
class Cell implements Comparable<Cell>{
private String first;
private SortedSet<String> others;
public int compareTo(Cell c){
return this.first.compareTo(c.getFirst())
}
public void addOther(String s){
others.add(s);
}
//略...
}