Adding some sorting code