This question already has an answer here:
Say we have a column in table or a property in a collection called "sortOrder" which simply is an integer which denotes which order it is to appear when displayed.
I am trying to figure out the simplest way to implement this, considering that when we insert a new row in the table it may have a sort order which bisects the current list - so then I guess we'd have to update all the rows where the sortOrder field value is greater than or equal to the newly inserted item.
Has anyone had this problem, how did you solve it?
Here is a question that illuminates the problem if you don't get it: