Similarly to Andreas_D, here's another way to skin that cat.
I would like to say that I still agree with Dori, this really does look like database data. I'd recommend you use a database and save yourself the headache of solving this problem that's already been solved.
Either that or work with the owner of the API you're using to get this data and get them to use a proper database query to merge it before it ever gets to you.
Forgoing that, your best bet is to do something like this to get to that point so that you can use the utilities of hashmap.
....
HashMap<String, HashMap<String, String>> unifiedMap = new HashMap<String, HashMap<String, String>>();
for (HashMap<String, String> teamMap : teamList) {
String teamId = teamMap.get("TeamID");
HashMap<String, String> mapFromUnified = unifiedMap.get(teamId);
if (mapFromUnified == null) {
unifiedMap.put(teamId, teamMap);
} else {
for (String key : teamMap.keySet()) {
// this will be a race condition, the last one in wins - good luck!
mapFromUnified.put(key, teamMap.get(key));
}
}
}
for (HashMap<String, String> teamMap : chanceList) {
String teamId = teamMap.get("TeamID");
HashMap<String, String> mapFromUnified = unifiedMap.get(teamId);
if (mapFromUnified == null) {
unifiedMap.put(teamId, teamMap);
} else {
for (String key : teamMap.keySet()) {
// this will be a race condition, the last one in wins - good luck!
mapFromUnified.put(key, teamMap.get(key));
}
}
}
....