some sort of non recursive sorting