Added return value to sortAndTraverseGrid to count for tiles moved or found per direction