Schedule sorting code finshed, but untested.