Grouping By Key (Code)

<xsl:for-each-group select="cities/city"
                    group-by="@country">
  <tr>
   <td><xsl:value-of select="position()"/></td>
   <td><xsl:value-of select="@country"/></td>
   <td>
    <xsl:value-of select="current-group()/@name"
                  separator=", "/>
   </td>
  </tr>
</xsl:for-each-group>