The optimizer checks whether the query tree contains unnecessary sort nodes. For example, when an SQL statement contains both a GROUP BY clause and an ORDER BY clause that refers to the same column, at most one sort is needed.
A sort node is also redundant when the immediate descendant node of the sort node is an index bracket scan on the sort column. That is, the sort is redundant when the data input to the sort was read using an index with the needed sort order.