I checked a few comparator posts, but I was stuck in one place.
The comparator I use:
@Override public int compare(BaseFolder arg0, BaseFolder arg1) { try { Object value1 = arg0.getName(); Object value2 = arg1.getName(); Collator lithuanianCollator = Collator.getInstance(new Locale("lt_LT")); lithuanianCollator.setStrength(Collator.PRIMARY); int value = lithuanianCollator.compare(value1.toString(), value2.toString()); return SortOrder.ASCENDING.equals(sortOrder) ? value : -1 * value; } catch(Exception e) { throw new RuntimeException(); } }
It really sorts, but it doesn’t work on Lithuanian letters, and I had no idea why.
EDIT: for some reason, sorting depends on the length of the string.
For instance.

EDIT:
public class BaseFolder { private String id; private String name; private String description; private String lastModifiedBy; private String lastModificationDate; private String createdBy; private String creationDate; private String parentId; public BaseFolder() { } public BaseFolder(CmisObject obj) { this.id = obj.getId(); this.name = obj.getName(); this.description = obj.getDescription(); this.lastModificationDate = DateFormatUtils.format(obj.getLastModificationDate().getTime(), "yyyy-MM-dd"); this.lastModifiedBy = obj.getLastModifiedBy(); this.createdBy = obj.getCreatedBy(); this.creationDate = DateFormatUtils.format(obj.getCreationDate().getTime(), "yyyy-MM-dd"); } public BaseFolder(String id, String name, String description, String parentId) { super(); this.id = id; this.name = name; this.description = description; this.parentId = parentId; } public Map<String, Object> getProperties() { Map<String, Object> properties = new HashMap<String, Object>(); properties.put(PropertyIds.PARENT_ID, "cmis:parentId"); properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder"); properties.put(PropertyIds.NAME, getName()); properties.put(PropertyIds.DESCRIPTION, getDescription()); return properties; }
Using java 8, Primefaces, JSF
source share