# Sort data in sub level

**URL:** <https://discuss.elastic.co/t/sort-data-in-sub-level/312166>\
**Category:** Elasticsearch\
**Created:** [August 16, 2022, 10:11am UTC](https://discuss.elastic.co/t/sort-data-in-sub-level/312166 "2022-08-16T10:11:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![aneesh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aneesh/32/37819_2.png) [@aneesh](https://discuss.elastic.co/u/aneesh)\
**Post date:** [August 16, 2022, 10:11am UTC](https://discuss.elastic.co/t/sort-data-in-sub-level/312166/1 "2022-08-16T10:11:04Z")

</div>

i am doing a sorting for a column that is in sub level. The issue there is , the sub level contains an array and i want to sort the data depending on the condition.  
My data looks like below  
I need to do sorting on column "SubColumn.S\_Text" where the Id = 2.  
That means for sorting only those rows should be considered where Id is equal to 2.  
I tried few ways as per documentation but could not achieve that.  
Can you please help me with this query?

{  
"Column1" : "XXX",  
"SubColumn" : [  
{  
"S1" : "EA355E4B-F0A4-46AE-A7A3-E44A01ED6CAE",  
"S\_Text" : "A\_SampleName",  
"Id" : 2  
},  
{  
"S1" : "DCC3AC3B-C7E8-4683-997A-3B12E5BB3675",  
"S\_Text" : "B\_mpleName",  
"Id" : 3  
}  
]  
},  
{  
"Column1" : "YYYY",  
"SubColumn" : [  
{  
"S1" : "BA355E4B-F0A4-46AE-A7A3-E44A01ED6CAE",  
"S\_Text" : "D\_SampleName",  
"Id" : 2  
},  
{  
"S1" : "DCC3AC3B-C7E8-4683-997A-3B12E5BB3675",  
"S\_Text" : "F\_SampleName",  
"Id" : 3  
}  
]  
},  
........

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [September 13, 2022, 10:11am UTC](https://discuss.elastic.co/t/sort-data-in-sub-level/312166/2 "2022-09-13T10:11:55Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
