2

I'm trying to sort a range that is populated by a filter and various functions. Whenever I try and apply a "filter" (the upside down triangle in the toolbar) and try and sort names or numbers from low to high it just unsorts itself after a second or so.

enter image description here

An example image of the ranges I would like to sort, whenever I try they just unsort themselves.

How do you sort ranges that are populated by a Filter(), Sort(), or Importrange() type of function?

2

If you are using a function that outputs an array, you are going to get that array. Trying to sort the output won't do any good: the function was asked to produce a certain array, and so it does.

But you can use another sort to produce output sorted in a desired way. If you will need multiple ways of sorting, this can be arranged using data validation and match function.

Suppose your range to sort is in columns A-C, with these headers.

+---+------+-------+--------+
|   |  A   |   B   |   C    |
+---+------+-------+--------+
| 1 | Name | Title | Salary |
+---+------+-------+--------+

I will set up a sortable version of this in columns E-F.

E1 ={A1:C1}
E2 =sort(A2:C, match(D2, A1:C1, 0), true)

The cell D1 would have text "Sort by:" and cell D2 have Data Validation of the type "Value from a range", the range being A1:C1.

Result:

  • a user selects the column to sort by in cell D2 (using a dropdown provided by data validation)
  • match finds the number of this column
  • sort sorts by it, with the sorted array appearing in columns E-F.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.