<p>I have a <code>DataTable</code> with a <code>Name</code> column. I want to generate a collection of the unique names ordered alphabetically. The following query ignores the <em>order by</em> clause.</p>

<pre><code>var names =
    (from DataRow dr in dataTable.Rows
    orderby (string)dr["Name"]
    select (string)dr["Name"]).Distinct();
</code></pre>

<p>Why does the <code>orderby</code> not get enforced?</p>

The problem is that the Distinct
 operator does not grant that it will
 maintain the original order of
 values.
So your query will need to work like this
```
```
var names = (from DataRow dr in dataTable.Rows
             select (string)dr["Name"]).Distinct().OrderBy( name => name );
```
```