EDIT: I\'m not sure that my original question is clear enough. I need an algorithm that will compute the minimal sequence of moves to rearrange an array from one ord
My first thought is you should use Selection sort instead of the built-in sort method, since it makes the lowest ammount of swaps needed. That way you can just move the DOM element around when moving the id in the list.