Shortened the sorting function.