# Minimum number of steps to sort 3x3 matrix in a given way

So I started practicing some algorithms and programming before university starts and I ran into this problem:

Given a 3x3 matrix containing the numbers from 0 to 8, find the minimum number of steps required to sort the matrix in the following format:

1 2 3
4 5 6
7 8 0

In one move it is only allowed to pick a cell that is adjacent to the cell which contains the 0 and swap those two cells.

Now, I am really stuck with this one and have no idea how to begin. Any tips and ideas to get me started are appreciated.

• I'm not sure what you mean. The input might be in the correct format already, so the answer to the question you've asked is "zero". Sep 7, 2015 at 17:38
• the question is nontrivial if 0-9 designations are taken as the order of the elements & not the elements themselves. if that is the case the question should be revised to make that clear.
– vzn
Sep 7, 2015 at 22:45
• eg there is ongoing research into minimal size sorting networks & that area may contain the answer published somewhere
– vzn
Sep 7, 2015 at 23:02