# 9.3 SORT आणि SORTBY

Source: https://ravindrabagale.com/mr/excel/ch09-dynamic-arrays/9-3-sort-and-sortby.html
Language: mr (Marathi with English technical terms)

=SORT(array,[sort_index],[sort_order],[by_col])
=SORTBY(array,by_array1,[sort_order1],[by_array2,sort_order2],…)

1 म्हणजे ascending, −1 descending. SORTमध्ये output arrayतील column number; SORTBYमध्ये explicit sort column द्यायचा.

Examples

=SORT(tblMini,7,-1)
=SORTBY(tblMini,tblMini[City],1,tblMini[Amount],-1)
=SORTBY(tblMini[Order ID],tblMini[Mins],1)
=SORT(FILTER(tblMini,tblMini[City]="Pune"),7,-1)

पहिला Amount descending. दुसरा City A–Z, प्रत्येक Cityमध्ये Amount high-to-low. तिसरा फक्त IDs दाखवतो पण Minsवर sort करतो. या sampleमध्ये BLK-1006 (8), BLK-1001 (9), AMN-1008 (10) आधी येतात.

शेवटचा formula Pune rows निश्चित उपलब्ध असलेल्या exampleसाठी. Dynamic selectionमध्ये no-match हाताळण्यासाठी आधी COUNTIFने count तपासा; “No orders” या single cellवर column 7 sort करण्याचा प्रयत्न करू नका.

Column numberचा अर्थ

तीन columnsचा helper array असेल तर Amount तिसरा असू शकतो. Original sheetचा सातवा column म्हणून 7 दिल्यास #VALUE! येऊ शकतो. SORTBYमध्ये sort arrayची row count outputशी जुळली पाहिजे.

Practice

Platformनुसार, मग Amount descending sort करा:

=SORTBY(tblMini,tblMini[Platform],1,tblMini[Amount],-1)

नंतर फक्त Order IDs delivery timeनुसार दाखवा. Source Tableचा physical order बदलला नाही, नवीन sorted output तयार झालं आहे हे पाहा.

रवींद्र बागले यांची tip

SORT source बदलत नाही. Sheetवरचा Data › Sort आणि formulaचा SORT यात हा उपयोगी फरक आहे.
