Search code examples
arrayssortinggoogle-sheetsgoogle-sheets-formulagoogle-sheets-query

Sort Data By the 2nd Last Letter in a cell then the first- Google Apps Script / Google Sheets


In the image shown (highlighted Bright Green G:H), I would have liked to sort the data according to the 2nd last letter - not the first. This would have meant F01A1 should have been appeared higher in list than E09C1, and then would have been selected in the A column.

How could I have the data Sorted by 2nd Last Letter in Cell, in Column G:H ?

enter image description here


Solution

  • try in row 1:

    =ARRAYFORMULA(QUERY({G:H, RIGHT(H:H, 2)}, "select Col1,Col2 order by Col3", 0))