D
David P. Donahue
I've been looking around for ways to sort the rows in a DataTable, and
everything seems to point to just changing the Sort property on that
DataTable's DefaultView property. That's all well and good for viewing
it sorted, but I need it to actually _be_ sorted, and testing seems to
show that the view doesn't do the trick. If I iterate through the rows
in my code and look at the sorted column in each step, it's not sorted.
Now, I can sort in my query easily enough before populating the
DataTable, but in this particular case this DataTable gets built through
multiple identical-result-schema queries which execute, perform some
other logic, and then append their data to the main DataTable. Thus,
sorting in each query would still result in the final DataTable being
unsorted.
Is there an easy way to actually sort the rows in the DataTable? Should
the Sort property on the DefaultView be doing the trick if used
properly? Or am I going to have to write a sorting algorithm to do this
(not difficult, but performance is key and I'm hoping that the language
has something built-in to out-perform whatever I write)?
Regards,
David P. Donahue
(e-mail address removed)
http://www.cyber0ne.com
everything seems to point to just changing the Sort property on that
DataTable's DefaultView property. That's all well and good for viewing
it sorted, but I need it to actually _be_ sorted, and testing seems to
show that the view doesn't do the trick. If I iterate through the rows
in my code and look at the sorted column in each step, it's not sorted.
Now, I can sort in my query easily enough before populating the
DataTable, but in this particular case this DataTable gets built through
multiple identical-result-schema queries which execute, perform some
other logic, and then append their data to the main DataTable. Thus,
sorting in each query would still result in the final DataTable being
unsorted.
Is there an easy way to actually sort the rows in the DataTable? Should
the Sort property on the DefaultView be doing the trick if used
properly? Or am I going to have to write a sorting algorithm to do this
(not difficult, but performance is key and I'm hoping that the language
has something built-in to out-perform whatever I write)?
Regards,
David P. Donahue
(e-mail address removed)
http://www.cyber0ne.com