Other

Database Row Sort Order Question

To sort content in a hierarchy i have rows that have a sort_order column, like the following list.

id, title, sort_order
1, page a, 0
2, page b, 1
3, page c, 2
4, page d, 3
5, page e, 4

My question is when changing the order or deleting content, is it best to keep the sort_order clean without gaps in numbers?  or does it matter?

Clean
1, page a, 0
2, page b, 1
5, page e, 2 – moved up several rows and reordered
3, page c, 3 – the following items are then renumbered as well
4, page d, 4

Gaps (may occur after deleting an item or by just moving an item to the end)
1, page a, 0
(sort_order gap of number 1)
3, page c, 2
4, page d, 3
5, page e, 4
2, page b, 5 – moved to the end and just given a number one greater than the max sort_order number.

The desired affect is still achieved.  I’m just not sure there is any reason to worry about the gaps or not.  Hit me  up on twitter with comments or FB.