# Custom sorting

**URL:** <https://discuss.elastic.co/t/custom-sorting/360530>\
**Category:** Elasticsearch\
**Created:** [May 30, 2024, 5:21am UTC](https://discuss.elastic.co/t/custom-sorting/360530 "2024-05-30T05:21:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![alexander.korkhov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alexander.korkhov/32/133918_2.png) [@alexander.korkhov](https://discuss.elastic.co/u/alexander.korkhov)\
**Post date:** [May 30, 2024, 5:21am UTC](https://discuss.elastic.co/t/custom-sorting/360530/1 "2024-05-30T05:21:28Z")

</div>

Good afternoon!  
We need to do custom sorting in elastic. You need to give elastic a list of document IDs as input, according to which you need to sort the output. That is, we first sort by this list (to the top of the output), and the remaining output by another field in the elastic. How can I do that?

---

<div class="post-metadata">

**Author:** ![jessgarson](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jessgarson/32/129841_2.png) [@jessgarson](https://discuss.elastic.co/u/jessgarson)\
**Post date:** [June 7, 2024, 10:56pm UTC](https://discuss.elastic.co/t/custom-sorting/360530/2 "2024-06-07T22:56:39Z")

</div>

Thanks for reaching out, @alexander.korkhov. Would something [like this](https://www.elastic.co/guide/en/elasticsearch/reference/current/sort-search-results.html) work for you?
