This is remarkably straightforward. You'll want to write a custom Comparator
for this, and enforce its comparison logic to behave the way you want with respect to your two separate "fields".
The motivation here is that these fields are lexicographically compared to one another for the date portion, as well as the alphabetical string portion. If you find that the date comparison isn't giving you accurate results (and it may not; I'm not sure of any cases that it wouldn't work off hand, though), then convert it to a Date
and compare that in-line.
Collections.sort(entries, new Comparator<String>() {
@Override
public int compare(String left, String right) {
String[] leftFragments = left.split("[|]");
String[] rightFragments = right.split("[|]");
if(leftFragments[0].compareTo(rightFragments[0]) == 0) {
return leftFragments[1].compareTo(rightFragments[1]);
} else {
return leftFragments[0].compareTo(rightFragments[0]);
}
}
});