Search code examples
sortinggoogle-sheetsgoogle-sheets-formulaspreadsheetgoogle-query-language

Sort Column header based on row value, and show as columns


We have sheet with column names and values in the cells below. We like to have a list of the names and the value next to it ordered.

example.

A B C D E
1 John Mary Tom Grace
2 3 4 5 2

and we would like the same data below which looks like...

A B
1 Tom 5
2 Mary 4
3 John 3
4 Grace 2

Any ideas? Thanks


Solution

  • use:

    =SORT(TRANSPOSE(A1:D2), 2, )
    

    enter image description here

    or:

    =SORT(TRANSPOSE({A1:D1; A4:D4}), 2, )
    

    enter image description here