# Sort value

**URL:** <https://discuss.elastic.co/t/sort-value/92773>\
**Category:** Elasticsearch\
**Created:** [July 12, 2017, 7:50am UTC](https://discuss.elastic.co/t/sort-value/92773 "2017-07-12T07:50:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chanpiseth\_Ros](https://avatars.discourse-cdn.com/v4/letter/c/c4cdca/32.png) [@Chanpiseth\_Ros](https://discuss.elastic.co/u/Chanpiseth_Ros)\
**Post date:** [July 12, 2017, 7:50am UTC](https://discuss.elastic.co/t/sort-value/92773/1 "2017-07-12T07:50:07Z")

</div>

Hi everyone,

if i have a values:

- "eee-ccc"

- "aaa-ttt"

- "ppp-bbb"

And i want to sort value that has a special character **-** in the middle of each value. I always get an error while sorting, it's not order from A-Z, Could anyone help me, and provide me the code?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [July 12, 2017, 8:06am UTC](https://discuss.elastic.co/t/sort-value/92773/2 "2017-07-12T08:06:43Z")

</div>

Follow some advices available at [About the Elasticsearch category](https://discuss.elastic.co/t/about-the-elasticsearch-category/21) and provide a full script so we can understand what exactly your problem is.

I suspect you are using an old elasticsearch version and doing sorting on a `string` field. But I can't tell more without details.

Anyway, in 5.x you should use a `keyword` field type to do the sorting on.

---

<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:** [August 9, 2017, 8:06am UTC](https://discuss.elastic.co/t/sort-value/92773/3 "2017-08-09T08:06:43Z")

</div>

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