Grid sorter + tests