Started adding sorting code