9.3 SORT and SORTBY
=SORT(array, [sort_index], [sort_order], [by_col])– sort by a column number inside the array; order 1 = ascending, -1 = descending.=SORTBY(array, by_array1, [sort_order1], [by_array2, sort_order2], …)– sort by any array, even one not shown.
| Need | Formula |
|---|---|
| Orders by Amount, largest first | =SORT(tblMini, 7, -1) |
| By City A–Z, then Amount high–low | =SORTBY(tblMini, tblMini[City], 1, tblMini[Amount], -1) |
| Order IDs sorted by delivery time (show only IDs) | =SORTBY(tblMini[Order ID], tblMini[Mins], 1) |
| Pune orders sorted | =SORT(FILTER(tblMini, tblMini[City]="Pune"), 7, -1) |
Worked example. =SORTBY(tblMini[Order ID], tblMini[Mins], 1) starts with BLK-1006 (8 mins), BLK-1001 (9), AMN-1008 (10)…
Ravindra Bagale's Tip
SORT madhe sort_index ha array madhla column number aahe, sheet cha nahi. FILTER kelelya 3 columns var SORT lavla tar Amount column 3 asel, 7 nahi – khup students ithe #VALUE! miltat. Shanka asel tar SORTBY vapra – column naavane sort hota.
Practice task
Show all orders sorted by Platform then Amount (high to low). Show Order IDs sorted by delivery time without displaying the time column.