Got sorting working properly