title: Neo4j Cypher Sorting and adding results of a list with multiple duplicates
body: <p>So i've got this graph database which has 20 football teams in nodes called "Team", with the only attribute being their name and a constraint ensuring uniqueness. Ive also got over 350 football matches again in nodes called "Match", with the attributes such as the date, team 1 score, team 2 score. The matches nodes have are linked in such a way that team 1 is the home_team and team 2 is the away_team so the relationship is like this:</p>
  
  <pre><code>MERGE (m)-[:away_team]-&gt;(t1)
  MERGE (m)-[:away_team]-&gt;(t2)
  </code></pre>
  
  <p>So far all of what I mentioned has worked, however now I am trying to display the team with the most wins in January. I managed to get a return with the teams in each match, and their result. It looks like this (the code is below the image)</p>
  
  <p><a href="https://i.stack.imgur.com/S5NXx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/S5NXx.png" alt="enter image description here"></a></p>
  
  <pre><code>MATCH (m:Match)-[:home_team]-&gt;(home_team:Team), (m:Match)-[:away_team]-&gt;(away_team:Team)
  WHERE m.date CONTAINS 'Jan'
  WITH m as matches, [home_team, away_team] as teams
  return teams, collect (matches.home_score) AS home_result, collect (matches.away_score) AS away_result
  </code></pre>
  
  <p>After getting to this point I got stuck. Im not entirely sure where go from here. The issue is since one team will play multiple matches in January and they can be either home or away so their result is spread between two columns and Im not entirely sure how to extract it and associate the team result to the team name and then display the highest score from the won matches. Any help is greatly appreciated! </p>
  
  <p>P.S. Im new to Cypher/Neo4j </p>