Added a method to find the closest Entity when changing the row order of an Entity.

This method ensures that the closest Entity would be found, not an
Entity which is either +1 or -1 from the current row_order.
When two Entities have a row_order gap of more than 1, the code now
makes sure they are changed to have a gap of 1, which means that the
row_order can be in the correct incremental order. It also means it
should not break if they were in the previous version of the code.