Moved all sorting parameters to a single sort function

Multiple sorts in a row did not conserve the previous ordering. By moving all the parameters to a single sort function, we should be able to get the desired results