――Because it's a good idea (?) With stream api
Development PC: Windows 10 Java: 8
--Japanese name is included in Model.name
Collator collator = Collator.getInstance( Locale.JAPANESE );
collator.setStrength(Collator.IDENTICAL);
collator.setDecomposition(Collator.FULL_DECOMPOSITION);
List<Model> kanaSortedModelList = modelList.stream()
.sorted(Comparator.comparing(Model::getName, Comparator.nullsLast(collator)))
.collect(Collectors.toList());
Comparator.naturalOrder () was a bit unnatural in unicode order ...
Recommended Posts