# What is a viable way of finding the minimum swaps to sort numbers in pyramid?

I have made a game that consists of a pyramid of hexagons with numbers from 00 to 99 randomly positioned in groups of 6, 10 or 15 elements. Now, I'm working to create an auto-solver but for the last 2 weeks, I have got nothing really worth produced, and would like your help. My objective is to determine the minimum swaps need to turn the left pyramid into the right pyramid:

Obviously, there's a catch: every cell can be exchanged only with it's neighbors cells, as below:

I've tried a lot of approaches with binary heap, BST and others, but I can't seems to find a proper answer. What would be the best algorithm choice to determine the minimum swaps needed to sort this hive?

Thanks in advance for any help,

Marcelo

What you also need for A* is function estimating the distance to goal state. Choosing good one is the key to speed of the algorithm, however pretty much any decent one will lead to the solution. I suggest using the sum of distances to goal postion, e.g. "1" is 1 swap away from its place, similarly "3" is two swaps away, all summing up to distance = 8 for the state in your example.