sort and input