This is probably a simple question. Let's say I have a small list with around 20-50 entries or so. Something like:
class Item
{
int ItemNumber;
int OrderNumber;
string Name;
}
stored in something like
List<Item>
This is stored either in a generic list or array in where the OrderNumber goes from 1, 2,3,4,....50. To makes things easier, let's assume that the OrderNumber has already be sorted in the List by QuickSort somewhere else (unless that makes things more complicated).
Let's say I want to move Item.OrderNumber = 30 into the spot taken by Item.OrderNumber = 20 or something like that. When I do that, everything above 20 now needs to be shifted so that the old 20 is now 21, 21 is now 22, etc until I makes it to 30. It also needs to go the other way so when Item.OrderNumber = 30 is moved to Item.OrderNumber = 34 and everything has to be shifted downwards.
I'm thinking about bubbling the list a few times, but I'm hoping there's a better way to do this. Although the list size is small, this needs to done a lot for various different things.
EDIT: Just to let you know. The results eventually have to be stored in a database, in some type of transaction.