7
I currently have the following scenario functional:
A list of the Studios class with id and name: List<Studios> studios;
I count the names repeated on List thus: 
Map<String, Integer> counts = new HashMap<>();
studios.forEach(studio -> counts.merge(studio.getName(), 1, Integer::sum));
In the Map<String, Integer> counts I have as key the name and as value the repetition total found in the List studios: Key = "Xpto", value = 5.
I order the return of Map counts in this way:
result = counts.entrySet().stream()
    .sorted(Collections.reverseOrder(Map.Entry.comparingByValue()))
    .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, 
        (e1, e2) -> e2, LinkedHashMap::new));
Getting how json works:
{
    "Studio1": 6,
    "Studio3": 5,
    "Studio2": 4
}
My need is to pass a dto at the time of sorting to get the return of json as follows:
{
  "studios": [
    {
        "name": "Studio 1",
        "cout": 6
    },
    {
        "name": "Studio 2",
        "count": 5
    }
  ]
}
Minha Dto:
public class Dto {
    private String studioName;
    private Integer count;
}
Note: Open to suggestions on how to improve the code will be welcome.
Hit the +1 vein.
– DNick