I've built a solution that allows users to sort records in a custom order. Users can select the records they want and then move them up or down the list. They can select multiple or single records. It uses a global field to store the record id's.
When a user clicks sort it uses the midpoint theorem to change the value of either the next or previous record. EG. if I press down on the below list it will change the value '11' to '5.5' [(6+5)/2] and then resort the list.
Unfortunately i have just found an issue with this. Eventually we get to a point where we can't divide by 2 anymore because they will actually equal the same number.
(5.9999999999999999 + 6)/2 = 6
is the same as
(6+6)/2 = 6
I wonder if there maybe is a better way of doing this? I imagine I may just need to loop through and change all the sort numbers in the users selected list. I am wary that this could cause issues if other users are moving the same records around, changing just one records value in this respect was much more appealing.
Any advice would be much appreciated