# Bucket sorting

**URL:** <https://discuss.elastic.co/t/bucket-sorting/148144>\
**Category:** Elasticsearch\
**Created:** [September 11, 2018, 1:42pm UTC](https://discuss.elastic.co/t/bucket-sorting/148144 "2018-09-11T13:42:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bert\_vervaele](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bert_vervaele/32/36142_2.png) [@bert\_vervaele](https://discuss.elastic.co/u/bert_vervaele)\
**Post date:** [September 11, 2018, 1:42pm UTC](https://discuss.elastic.co/t/bucket-sorting/148144/1 "2018-09-11T13:42:20Z")

</div>

Hi,

I was wondring if a new feature of Elastic 6 could help me.  
But before I upgrade everything from 5.2.2 I would like to check it first.

My problem:  
I want an aggregation to be sorted based on the sum of all it's sub aggregations.  
In the example underneath I would like the top levels to be sorted by the sum of there sub aggregations (the value in pencel).

 ![sorting](https://us1.discourse-cdn.com/elastic/original/3X/2/1/2121123121e935dc2d5deaff99ae29fbd198dd01.jpeg)

Is it possible to use [Bucket sort aggregation](https://www.elastic.co/guide/en/elasticsearch/reference/6.2/search-aggregations-pipeline-bucket-sort-aggregation.html) for this?  
Or is there an other way to do this?

Kind regards,  
Bert

---

<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:** [October 9, 2018, 1:53pm UTC](https://discuss.elastic.co/t/bucket-sorting/148144/2 "2018-10-09T13:53:19Z")

</div>

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