Here's an algorithm to find a solution using the shortest possible number of moves. It assumes that you know the proper order for the tapes, which you should, because figuring that out requires zero moves.
in reply to sort with fewest moves
If there are N tapes that are not in the right slots, clearly each tape must be moved at least once, for a minimum of N moves. However, in order to move a tape, the destination slot must be empty, so one extra move is required to first move a tape into slot 0. Therefore, the above algorithm, which takes N+1 steps, finds a shortest solution.
- Starting at slot 1, find the first tape that is not in the right slot.
- Move that tape to slot 0.
- Since that tape was not in the right slot, there is another tape which belongs in that slot. Find that tape and move it into the right slot.
- Repeat the previous step until the tape in slot 0 is moved into the right slot.