あなたの例の "" が何であるか完全にはわからないので、これは完全に正しいとは限りませんが、タイムスタンプ文字列を同等のオブジェクトに変換する方法を示しています。うまくいけば、これで正しい軌道に乗ることができます。
DateFormat dateFormat = new SimpleDateFormat("MMM dd yyyy")
List<String> lines = readLines(); // use a function of your to read the lines
List<LogEntry> entries = new LinkedList<LogEntry>();
for ( String line : lines ) {
int splitIndex = line.indexOf("<log>");
String time = line.substring(0,splitIndex);
Date date = dateFormat.parse(time);
entries.add(new LogEntry(date,line.substring(splitIndex));
}
Collections.sort(entries);
// create a class to hold the log contents and the timestamp
class LogEntry implements Comparable<LogEntry> {
private final Date time;
private final String entry;
public void compare(LogEntry other) {
return time.compareTo(other.time);
}
}
編集:ペーストビンで作成したコードを実行したところ、出力は
Fri Jul 29 17:09:50 EDT 2011 <phl0w> tes
Sun Jul 31 17:08:49 EDT 2011 <yyyy> alewrwae
Sun Jul 31 17:09:50 EDT 2011 <phl0w> tes
Sun Jul 31 17:10:49 EDT 2011 <Andy_> Speed
Sun Jul 31 17:10:51 EDT 2011 <Andy_> lol Speed
Sun Jul 31 17:11:51 EDT 2011 <xxxx> wrkjaer
Sun Jul 31 19:20:50 EDT 2011 <phl0w> lolfile1
Sun Jul 31 19:20:53 EDT 2011 <phl0w> lolfile3