# Sorting a string field numerically

**URL:** <https://discuss.elastic.co/t/sorting-a-string-field-numerically/9488>\
**Category:** Elasticsearch\
**Created:** [October 28, 2012, 6:44pm UTC](https://discuss.elastic.co/t/sorting-a-string-field-numerically/9488 "2012-10-28T18:44:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Axsuul](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/axsuul/32/2663_2.png) [@Axsuul](https://discuss.elastic.co/u/Axsuul)\
**Post date:** [October 28, 2012, 6:44pm UTC](https://discuss.elastic.co/t/sorting-a-string-field-numerically/9488/1 "2012-10-28T18:44:46Z")

</div>

I have a field that is string type. Sometimes it will contain integer values  
such as 1, 2, 10, 20. Currently how it sorts those is 1, 10, 2, 20. How do I  
go about sorting that numerically so that it's 1, 2, 10, 20?

--  
View this message in context: [http://elasticsearch-users.115913.n3.nabble.com/Sorting-a-string-field-numerically-tp4024556.html](http://elasticsearch-users.115913.n3.nabble.com/Sorting-a-string-field-numerically-tp4024556.html)  
Sent from the ElasticSearch Users mailing list archive at [Nabble.com](http://Nabble.com).

--

---

<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 6, 2017, 3:06am UTC](https://discuss.elastic.co/t/sorting-a-string-field-numerically/9488/2 "2017-07-06T03:06:57Z")

</div>


