I am writing an app which displays speeches on various topics, with each speech having a number of attributes. I want to give the user the choice to sort a list of speeches by an attribute, even within a previously sorted list of speeches.
Consider for example: Suppose the previous list had been sorted by the attribute: "speaker's name", and there were three different speakers (so the list was split into three windows with each window consisting of the same speaker). Now, the user wants to sort the speeches based on the attribute: "length of the speech" such that the new list would now be sorted by speaker's name, and within each window of the speaker's name, the speeches would be sorted by the length (creating a new window within this window for each length of speech in the speaker's window).
I would like to give the user the ability to do this with an arbitrary number of attributes. How can I go about doing such sorting, preferably in the most efficient way?
P.S: I am just a teenage programmer who has been programming for a few years and can understand algorithms in concrete steps - I have not taken college classes in CS, so please keep that in mind when explaining the algorithms.