79529335

Date: 2025-03-23 17:21:05
Score: 0.5
Natty:
Report link
lines.sort(Comparator.comparing((String line) -> line.split(" -> ")[0])
            .thenComparing(line -> {
                String secondPart = line.split(" -> ")[1];
                return secondPart.split(" ")[0];
            })
            .thenComparing((l1, l2) -> {
                int result = l1.split("\\[label=")[1].compareTo(l2.split("\\[label=")[1]);
                return result != 0 ? -result : 0;
            }));

Final solution came down to this, To anyone stumbling upon this, better solution would be to parse line into Object which has fields with those keywords and then just compare them like e.g:

Comparator.comparing(X::obj1)
    .thenComparing(X::obj2)
    .thenComparing(X::relType)
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: user28747840