Proper way of calculating rank in sortable list


Long time ago @avital published example how to create sortable list in meteor. In this example rank of the item after reordering calculated as average number between before and after ranks. But this method is not perfect because of javascript restrictions (can’t find proof link, but have read, that after many permutations errors are possible).
So, what is the best way of rank calculation in sortable list?