You could think of each List of String as a single Pojo that contains a team, country, and player. Then sort a list based on the team. You could of course sort by country if needed, or player if needed.
private static final class Entity {
private final String team;
private final String country;
private final String player;
private Entity(String team, String country, String player) {
this.team = team;
this.country = country;
this.player = player;
}
public String getTeam() {
return team;
}
public String getCountry() {
return country;
}
public String getPlayer() {
return player;
}
@Override
public String toString() {
return String.format("team=%s, country=%s, player=%s", team, country, player);
}
}
public static void main(String[] args) {
Entity a = new Entity("TEAMA", "COUNTRYA", "PLAYERA");
Entity b = new Entity("TEAMB", "COUNTRYF", "PLAYERB");
Entity c = new Entity("TEAMC", "COUNTRYR", "PLAYERC");
Entity d = new Entity("TEAMB", "COUNTRYA", "PLAYERD");
Entity e = new Entity("TEAMA", "COUNTRYA", "PLAYERE");
Entity f = new Entity("TEAMA", "COUNTRYF", "PLAYERF");
List<Entity> sorted = new ArrayList<>(Arrays.asList(a, b, c, d, e, f))
.stream().sorted(Comparator.comparing(Entity::getTeam))
.collect(Collectors.toList());
sorted.forEach(System.out::println);
}
Output:
team=TEAMA, country=COUNTRYA, player=PLAYERA
team=TEAMA, country=COUNTRYA, player=PLAYERE
team=TEAMA, country=COUNTRYF, player=PLAYERF
team=TEAMB, country=COUNTRYF, player=PLAYERB
team=TEAMB, country=COUNTRYA, player=PLAYERD
team=TEAMC, country=COUNTRYR, player=PLAYERC