Not sure if I understood it right, but what about parsing the Html into a HashMap
to get key-value pairs? That would get rid of duplication at least. Then you could do something like:
List<Employee> employeeById = new ArrayList<>(map.values());
Collections.sort(employeeById);
And get the results as:
[Employee{id=1, name='Mher'},
Employee{id=2, name='George'},
Employee{id=8, name='John'},
Employee{id=22, name='Annie'}]