I came across the following problem in the application I'm developing:
I'm given two lists:
list1 = { Z, K, A, B, A, C }
list2 = { A, A, B, C, K, Z }
list2 is the guaranteed to be the sorted version of list1.
My objective is to sort list1 only by swapping elements within list1. So for example, I cannot iterate through list2 and simply assign every element i in list1 to every element j in list2.
Using list2 as a resource, I need to sort list1 in the absolute minimum number of swaps possible.
Is there a set of algorithms specifically for this purpose? I've not heard of such a thing.