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 – such that, for example, if the previous list had been sorted by speaker and there were three speakers (so the list was split into three windows), and the user was now sorting by length, that the new list would be sorted by speaker, and within each window of speaker, the speeches would be sorted by length (creating a new window within this window for each length of speech in the speaker’s window). I would like to be able to give the user the ability to do this with an arbitrary number of attributes. I start with a flat list of speeches and need to end with a flat list of speeches to display. How can I go about sorting this list within each window, preferably in the most efficient way?