I will frequently require itemized lists for output to reports. The user will need to be able to arbitrarily customize the sort order of these items. That is the items won't necessarily be sorted by date/time or alphabetically or any predefined logical order. The user needs to be able to say this item is at the top of the list, this item goes before that one, this other one goes before that one, etc. Arbitrary sort order.
I figure at the time of reports that there will be line numbering but that will be handled dynamically by the report. BUT the reports could just be bullet point lists and not numbered lists.
So my question is what is the most efficient method to save custom arbitrary sort orders in the database?
At first thought I would simply have a SortOrder field in the table of an integer datatype. They would simply be sequential integers the report queries could sort by, and when the user moved an item around in the sort order I'd have a procedure to move the rest of the items in the list appropriately to make room. The user would have access to directly edit this integer. But I'm wondering if it would be wiser to use floating points. Each time an item is added to the list the SortOrder = previous item's SortOrder + an arbitrary large number. When an item is moved up and down the list instead of changing the SortOrder field of every item in the list that is affected all I'd have to do is make the SortOrder # of the item I'm moving greater than the item i'm moving it behind, and less than the item im moving it in front of.
For example:
Step 1) I add the first item A to the table and vba assigns arbitrary sort order # 1.0
Step 2) I add another item B with sort order # 1000.0
Step 3) I add another Item C with sort order # 2000.0
If I want to move C between A and B I simply set C's sort order # to (1.0 + 1000.0)/2=500.5. Of course the math would be handled behind the scenes and the user would never see the actual sort order field value. And as for UI i'm guessing something like a listbox where they select the item and have up and down command buttons to move the item up and down the list...
Any thoughts/issues? Examples? I'm guessing this has been done before, I don't want to reinvent the wheel over here.