Is this a bug with DataView.Sort
Data
Row0= ""
Row1= "T"
Row2= "S"
Sort Ascending
Returns data as
Row0, Row2, Row1.
Surely it should be Row2, Row1, Row0, this is how Excel
does it.
Dear BuddyWork
Most systems I've come across sort empty strings first - this is just
personal experience and by no means definitive.
Perhaps Excel's sorting is shaped by the possibility that an empty
string could be an empty row.
I know of no configuration option to change the default behavior
(which doesn't mean it doesn't exist).
It might be possible to override the sort behavior in the DataSet /
DataTable / DataView object model somewhere (maybe an implementation
of the IComparer interface somewhere). I'm afraid we don't use
DataSets that extensively.
If the change in sort behavior is critical then a *very* crude
solution might be to add an expression column...
Assuming you originally wanted to sort by a column called
"StringCol"...
sortCol = new DataColumn();
sortCol.DataType = System.Type.GetType("System.String");
sortCol.ColumnName = "SortString";
sortCol.DefaultValue = "";
sortCol.Expression = "iif(StringCol='','zzzzzzzzz',StringCol)";
myTable.Columns.Add(sortCol);
....
DataView myView = new DataView(myTable);
myView.Sort = "SortString";
Regards
Neil Allen
MSDN help on Expressions...
http://msdn.microsoft.com/library/d...fSystemDataDataColumnClassExpressionTopic.asp