Code Room
Code reviewHard
Question
Review this Java that sorts search results by a computed relevance score (descending) before paginating.
What a strong answer looks like
Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix — specific and kind.
Learn the concepts
List<Result> ranked(List<Result> results) { results.sort((a, b) -> { double sa = a.score(); // NaN when no signals fired double sb = b.score(); if (sa < sb) { return 1; // b ranks higher } if (sa > sb) { return -1; // a ranks higher } return 0; }); return results.subList(0, Math.min(20, results.size()));}Run or narrate your approach, then ask the coach.