Move row to top in data table c#
<p>I have a data table in which if the Addresses match move one of the rows to the top of the data table. I am using the following code but it doesnt work. Any idea how to achieve this. The data in the data table is imported from an excel file. I have tried the same if statement in GridView to highlight the duplicates and that works but I also want to move them to the top because the data has more than 1000 rows and its hard to move up and down again and again to check for the highlighted row.</p>

<pre><code>for (int row = 1; row &lt; dtf1.Rows.Count; row++)
{
    for (int rowinner = 1; rowinner &lt; dtf1.Rows.Count; rowinner++)
    {
        if (rowinner != row)
        {
            if (dtf1.Rows[row][addresscolno] == dtf1.Rows[rowinner][addresscolno].ToString())
            {
                DataRow newrow = dtf1.Rows[row];
                dtf1.Rows.RemoveAt(row);
                dtf1.AcceptChanges();
                dtf1.Rows.InsertAt(newrow, 1);
                dtf1.AcceptChanges();
                GridView1.DataSource = dtf1;
                GridView1.DataBind();
            }
        }
    }
}
</code></pre>
