Added grid sorting