Create some data type which carries the data relevant to sorting (it could be the
Value
of just one columns, or something else, depending on your sorting criteria) plus — importantly — the index in the grid view at the moment.
Collect all instances of this data type from the grid view and put all these instances in the instance of the list
System.Collections.Generic.List<T>
, where
T
should be this data type:
https://msdn.microsoft.com/en-us/library/6sh2ey19%28v=vs.110%29.aspx[
^].
Then sort this list using your comparison criteria:
https://msdn.microsoft.com/en-us/library/w56d4y5z(v=vs.110).aspx[
^].
—SA