I am struggling with some algorithm to handle re-ordering of a C# data table based on a a column value.
So, datatable, among other columns, has a RANK column. Through GUI, user can change the rank and I need to be able to re-order that data table based on rank.
The method I am using that is supposed to update the data table has an object parameter that contains the updated row's data, including new and old rank as well as unmodified data table content.
For instance, if initial table looks like below, with first column being rank:
1 A
2 B
3 C
4 D
5 E
and I change the rank of 3rd row from 3 to 5, it should look like
1 A
2 B
3 D
4 E
5 C
Or, if I change rank of 3rd row from 3 to 2, it would become:
1 A
2 C
3 B
4 D
5 E
I did not include anything I tried because none of them worked.