I have a list of books on Google Sheets that will be turned into a paged layout on InDesign. Each book has two additional information besides its title (year and theme). Like this
But I need this list to be structured in a stacked way. Grouping first by year, and then by theme, like this (I've formatted the cells just to clarify):
I currently do this stacking manually, and it requires quite a lot of time. Is there some sort of formula, or tool, to solve this problem? I guess it can be done with scripting, but I wanted to know if there's a non-scripting way to do it before diving into Google sheets script documentation.