I assume "direction" is "ASC" or "DESC" and dt contains a column named "colName"
public static DataTable resort(DataTable dt, string colName, string direction)
{
DataTable dtOut = null;
dt.DefaultView.Sort = colName + " " + direction;
dtOut = dt.DefaultView.ToTable();
return dtOut;
}
OR without creating dtOut
public static DataTable resort(DataTable dt, string colName, string direction)
{
dt.DefaultView.Sort = colName + " " + direction;
dt = dt.DefaultView.ToTable();
return dt;
}