Hello I have the following problem that I do not understand very well, I have been introducing myself to java but I still have problems
I want to order
Set<ConstraintViolation<?>> ex= ex.getConstraintViolations();
Collections.sort(ex, Comparator.comparing(ConstraintViolation::getMessageTemplate));
what I manage to achieve is to have all the errors, but I want to show one by one since currently without ordering how is a set and is not ordered
also failed to sort a list of fielderror
List<FieldError> err= ex.getFieldErrors();
Collections.sort(err);
I get the following error
The method sort(List<T>) in the type Collections is not applicable for the arguments (List<FieldError>)
What do I have to do to sort these lists and show the DefaultMessage or the MessageTemplate ordered and only an error?