# Giving wrong Sorting order

**URL:** <https://discuss.elastic.co/t/giving-wrong-sorting-order/6191>\
**Category:** Elasticsearch\
**Created:** [December 19, 2011, 9:05am UTC](https://discuss.elastic.co/t/giving-wrong-sorting-order/6191 "2011-12-19T09:05:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![narinder\_izap](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/narinder_izap/32/803_2.png) [@narinder\_izap](https://discuss.elastic.co/u/narinder_izap)\
**Post date:** [December 19, 2011, 9:05am UTC](https://discuss.elastic.co/t/giving-wrong-sorting-order/6191/1 "2011-12-19T09:05:57Z")

</div>

I am applying multiple sorting, on code, city and then name.The codes are:

AK  
AL  
AR  
AZ  
BH  
...................  
ZK

So expected result is that the document with AK should come first, then AL,  
then AR AND then AZ and so on...

but the sorting order is AL,AK,AZ,AR....  
can you tell me the reason? does sorting work only on first alphabet??

---

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [December 19, 2011, 9:19am UTC](https://discuss.elastic.co/t/giving-wrong-sorting-order/6191/2 "2011-12-19T09:19:39Z")

</div>

Hi Narinder

> So expected result is that the document with AK should come first,  
> then AL, then AR AND then AZ and so on...

> but the sorting order is AL,AK,AZ,AR....  
> can you tell me the reason? does sorting work only on first alphabet??

This should work. Please gist a complete example demonstrating the  
issue. See [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/help) for a guide to gisting  
examples.

clint

---

<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:44am UTC](https://discuss.elastic.co/t/giving-wrong-sorting-order/6191/3 "2017-07-06T03:44:59Z")

</div>


