How do I reverse an array in Google Sheets?

Viewed 2346

Suppose I have a long, unordered, and gradually growing column that I search the even numbers from.

=filter(A1:A,ISEVEN(A1:A)=TRUE)

Now I would like to reverse this result, so that the last even number in column A is listed first in the result. Many examples use helper columns or the row function, but that doesn't seem to be an option because you don't know how many even elements there are in this array before you begin. And even if I separately calculate that using rows I can't seem to figure it out. It seems like there should be a rather simple way to just "reverse" an array right?

2 Answers

use:

=INDEX(SORT(FILTER({A1:A, ROW(A1:A)}, ISEVEN(A1:A), A1:A<>""), 2, 0),, 1)

enter image description here

Try this:

=QUERY(FILTER({A:A,ROW(A:A)},ISNUMBER(A:A),ISEVEN(A:A)),"Select Col1 Order By Col2 Desc")
Related