Sort commits by date, so we only ever take the first branch that has the commit