Google-sheets – Sorting a sheet without losing group order

google sheetssorting

I've got a large sheet (tens of thousands rows) grouped into hundreds of different groups. All the groups are collapsed so I only see the top-level cell of each group. Now I want to sort on a these top-level cells. But when I do so, the collapsed groups don't move with the cells.

For a simple example, if I have the following sheet with 6 rows and 2 columns:

A
    A1
    A2
B
    B1
    B2

Select rows 2 and 3 and under the "Data" menu select "Group rows 2-3", then select 5 and 6 and "Group rows 5-6", then click on the "-" for each group to collapse it. Now "Data" -> "Sort sheet by Column A, Z -> A".

If I expand the groups after this, I see:

B
    A1
    A2
A
    B1
    B2

When what I need to see is this:

B
    B1
    B2
A
    A1
    A2

How can I accomplish this?

Update: As requested in the comments, here is a link to this simple example: Group Sort Test

However, I'm not sure how useful this is – I notice that in view only mode you aren't able to expand/collapse the groups or sort, and I'm not sure it's wise to allow any anonymous reader to have edit access.

Best Answer