From bb15c55e46fd53c68544d73d32163bd62bc192a8 Mon Sep 17 00:00:00 2001 From: Sebastiaan de Schaetzen Date: Sun, 15 Jun 2025 09:48:07 +0200 Subject: [PATCH] Improve asset sorting by brand, model, and QR code with null handling --- .../java/be/seeseepuff/pcinv/controllers/WebController.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/be/seeseepuff/pcinv/controllers/WebController.java b/src/main/java/be/seeseepuff/pcinv/controllers/WebController.java index c2eb028..32f49bc 100644 --- a/src/main/java/be/seeseepuff/pcinv/controllers/WebController.java +++ b/src/main/java/be/seeseepuff/pcinv/controllers/WebController.java @@ -96,7 +96,10 @@ public class WebController { model.addAttribute(DESCRIPTORS, tree); model.addAttribute(PROPERTIES, tree.stream().flatMap(d -> d.getProperties().stream()).toList()); var assets = assetService.getAssetsByType(type); - assets.sort(Comparator.comparing(Asset::getQr)); + assets.sort(Comparator + .comparing((Asset a) -> a.getAsset().getBrand(), Comparator.nullsFirst(Comparator.naturalOrder())) + .thenComparing((Asset a) -> a.getAsset().getModel(), Comparator.nullsFirst(Comparator.naturalOrder())) + .thenComparing(Asset::getQr)); model.addAttribute(ASSETS, assets); return "browse_type"; }