Google-sheets – How to combine and consolidate rows from multiple sheets into one and sort them

google sheetssorting

I've few sheets where rows are populated dynamically via IMPORTXML and ImportJSON with the same columns, but they can't be sorted.

So I'd like to generate new sheet which will populate rows from other sheets, so consolidated rows can be sortable. Copying won't help when feed will change as main sheet won't be up-to-date.


Example:

I'd like to consolidate these 3 YouTube Data feeds from different countries:

=ImportJSON("http://gdata.youtube.com/feeds/api/standardfeeds/GB/most_popular?v=2&alt=json", "/feed/entry/title,/feed/entry/content/src", "noInherit,noTruncate,rawHeaders")
=ImportJSON("http://gdata.youtube.com/feeds/api/standardfeeds/US/most_popular?v=2&alt=json", "/feed/entry/title,/feed/entry/content/src", "noInherit,noTruncate,rawHeaders")
=ImportJSON("http://gdata.youtube.com/feeds/api/standardfeeds/AT/most_popular?v=2&alt=json", "/feed/entry/title,/feed/entry/content/src", "noInherit,noTruncate,rawHeaders")

into one sheet and sort them by title.

Best Answer

Short Answer

Use arrays in Google Sheets and SORT() function.

Example

To combine the non continuous ranges A1:D5, H1:K100, P1:S15, the following formula will return a 4 X 120 array sorted by the first column in ascending order.

=SORT({A1:D5;H1:K100;P1:S15},1,TRUE)

The first parameter also could be any function that returns an array like IMPORTFEED.

Remarks

  • The URLs provided in example are not working because the YouTube Data API (v2) has been officially deprecated as of March 4, 2014.
  • IMPORTJSON() was retired of the new Google Sheets.

References