# Getting an array inside a document sorted

**URL:** <https://discuss.elastic.co/t/getting-an-array-inside-a-document-sorted/9597>\
**Category:** Elasticsearch\
**Created:** [November 7, 2012, 11:36am UTC](https://discuss.elastic.co/t/getting-an-array-inside-a-document-sorted/9597 "2012-11-07T11:36:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![azitabh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/azitabh/32/2647_2.png) [@azitabh](https://discuss.elastic.co/u/azitabh)\
**Post date:** [November 7, 2012, 11:36am UTC](https://discuss.elastic.co/t/getting-an-array-inside-a-document-sorted/9597/1 "2012-11-07T11:36:09Z")

</div>

Let's say this is the document indexed in elasticsearch:  
{:id=\>123,:a=\>10, :b=\>12, :c=\>[{:x=\>A,:y=\>102,:z=\>92},{:x=\>B,:y=\>110,:z=\>96},{:x=\>C,:y=\>94,:z=\>106}]}

And I am firing some query to elasticsearch and it's guaranteed that this will be the only document in the result set.  
Is there a way to instruct elasticsearch that the array 'c' in the returned document should be sorted on the basis of (y+3z).

Since the expression will be different every time, so I can't take care of this while indexing.

Thanks  
-Azitabh

---

<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:** [July 6, 2017, 3:05am UTC](https://discuss.elastic.co/t/getting-an-array-inside-a-document-sorted/9597/2 "2017-07-06T03:05:47Z")

</div>


