cursor.execute("select courseware_studentmodule.grade,COUNT(courseware_studentmodule.student_id) from courseware_studentmodule where courseware_studentmodule.module_id=%s group by courseware_studentmodule.grade",[module_id])
grades=list(cursor.fetchall())
printgrades
grades.sort(key=lambdax:x[0])# Probably not necessary