# Is it possible to sort a field that contains a hexadecimal string?

**URL:** <https://discuss.elastic.co/t/is-it-possible-to-sort-a-field-that-contains-a-hexadecimal-string/265295>\
**Category:** Elasticsearch\
**Created:** [February 24, 2021, 9:08am UTC](https://discuss.elastic.co/t/is-it-possible-to-sort-a-field-that-contains-a-hexadecimal-string/265295 "2021-02-24T09:08:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![htang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/htang/32/80140_2.png) [@htang](https://discuss.elastic.co/u/htang)\
**Post date:** [February 24, 2021, 9:08am UTC](https://discuss.elastic.co/t/is-it-possible-to-sort-a-field-that-contains-a-hexadecimal-string/265295/1 "2021-02-24T09:08:46Z")

</div>

I have a mapping as keyword which contains a hexadecimal string like:  
5f4b455cf6b841508fb1fa24

which is a 12 byte object. Is it possible to ask ES to sort on this field by value? I don't want lexicographic order.

For example, given values:

5f4b455cf6b841508fb1fa24 and  
5f4b455cf6b841508fb1fa1b

and I want to sort these in descending order, the result should return me

5f4b455cf6b841508fb1fa1b  
5f4b455cf6b841508fb1fa24

since the first one is larger than the second one by value.

---

<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:** [March 24, 2021, 9:09am UTC](https://discuss.elastic.co/t/is-it-possible-to-sort-a-field-that-contains-a-hexadecimal-string/265295/2 "2021-03-24T09:09:31Z")

</div>

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