# How to sort multiple field values in particular order?

**URL:** <https://discuss.elastic.co/t/how-to-sort-multiple-field-values-in-particular-order/91461>\
**Category:** Elasticsearch\
**Created:** [June 30, 2017, 3:33pm UTC](https://discuss.elastic.co/t/how-to-sort-multiple-field-values-in-particular-order/91461 "2017-06-30T15:33:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![SamA](https://avatars.discourse-cdn.com/v4/letter/s/7993a0/32.png) [@SamA](https://discuss.elastic.co/u/SamA)\
**Post date:** [June 30, 2017, 3:33pm UTC](https://discuss.elastic.co/t/how-to-sort-multiple-field-values-in-particular-order/91461/1 "2017-06-30T15:33:37Z")

</div>

I have a field called chocolate\_type. There are 4 different chocolate types ("Dark", "White", "Milk", "Sweet"). I want my documents to be sorted in a specific order based on the chocolate type. I do not want to sort the chocolate types in ascending or descending order. Instead, I want them to be sorted where white is first, dark second, milk third, and sweet fourth. Here's an example of how the documents should be sorted:

> id: 5,

> chocolate\_type: "White"

> id: 8,

> chocolate\_type: "White"

> id: 15,

> chocolate\_type: "Dark"

> id: 18,

> chocolate\_type: "Dark"

> id: 24,

> chocolate\_type: "Dark"

> . . .

How can I make a query that does this?

---

<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 28, 2017, 3:33pm UTC](https://discuss.elastic.co/t/how-to-sort-multiple-field-values-in-particular-order/91461/2 "2017-07-28T15:33:39Z")

</div>

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