How to Add xsl:sort for an xsl:for-each Statement

The xsl:sort statement can be added to an xsl:for-each statement to specify a field based on which sorting is performed. The xsl:sort instruction causes xsl:for-each to loop over the defined node-set in a particular order.