How do I make my HTML table sortable?

I’m putting together a website as a school project, which shows the results you got in each subject. I’d like my table to be sortable so that a user can select which column to sort on, just like Excel. How do I do this in HTML?