With the help of 2D-Sorting, we can find the correct function between direction and power of atoms.