fix(search): treat null sender.lastName as empty in sort key
A sender with lastName=null produced sort key "null Bob" which sorted before names starting with lowercase letters (n < s, t, u, v...). Now returns "" for null lastName, which the comparator places at end. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -32,6 +32,7 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
@@ -327,7 +328,8 @@ public class DocumentService {
|
||||
return documents.stream()
|
||||
.sorted(Comparator.comparing(doc -> {
|
||||
Person s = doc.getSender();
|
||||
return s != null ? s.getLastName() + " " + s.getFirstName() : "";
|
||||
if (s == null || s.getLastName() == null) return "";
|
||||
return s.getLastName() + " " + Objects.toString(s.getFirstName(), "");
|
||||
}, nullSafeComparator))
|
||||
.toList();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user