# Alphabetical sorting of numeric labels not working

**URL:** <https://discuss.elastic.co/t/alphabetical-sorting-of-numeric-labels-not-working/245940>\
**Category:** Kibana\
**Created:** [August 21, 2020, 5:10pm UTC](https://discuss.elastic.co/t/alphabetical-sorting-of-numeric-labels-not-working/245940 "2020-08-21T17:10:54Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dennis1](https://avatars.discourse-cdn.com/v4/letter/d/ecccb3/32.png) [@Dennis1](https://discuss.elastic.co/u/Dennis1)\
**Post date:** [August 21, 2020, 5:10pm UTC](https://discuss.elastic.co/t/alphabetical-sorting-of-numeric-labels-not-working/245940/1 "2020-08-21T17:10:55Z")

</div>

I'm trying to order the response code labels in my stacked bar graph to be descending alphabetical, but it doesn't appear to be working properly. Further, when I select 'ascending', the response codes are re-ordered in some other non-alphabetical order. Please see screenshots of both cases below.

I believe this is a bug, as I've had other issues with alphabetical sorting in the past. It seems to be sorting on some other field or metric.

 ![Screen Shot 2020-08-21 at 12.43.13 PM copy](https://us1.discourse-cdn.com/elastic/original/3X/2/1/2132ae862f729e3f692b79fa84b476b124b726ae.jpeg)  
 ![Screen Shot 2020-08-21 at 1.06.51 PM](https://us1.discourse-cdn.com/elastic/original/3X/f/c/fc2eef9f25e4b646ca6792d69b4cbb80c8554eb0.png)

---

<div class="post-metadata">

**Author:** ![cheiligers](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cheiligers/32/73114_2.png) [@cheiligers](https://discuss.elastic.co/u/cheiligers)\
**Post date:** [August 21, 2020, 7:25pm UTC](https://discuss.elastic.co/t/alphabetical-sorting-of-numeric-labels-not-working/245940/2 "2020-08-21T19:25:25Z")

</div>

@Dennis1, welcome to the community!  
In order to help you out, could you please let me know:

1. What version of the stack are you using?
2. How are you running kibana (from source, os etc)
3. What your index pattern mappings are for the data you're visualizing

In this case, your visualization is doing the date aggregation first and then splitting the terms within each date, resulting in a sort within each bucket. The legend displays a rather naive concatenation of these sorted results and I have a feeling that's what's happening here.

Could you try swopping the order in which you are doing the aggregations? In other words, bucket with a split series by terms first and then use a date histogram on the X-axis.

I tested my recommendation using the `kibana_sample_data_logs` index as shown in the screen shot below:

 ![Screen Shot 2020-08-21 at 12.51.23](https://us1.discourse-cdn.com/elastic/original/3X/0/b/0b7096f806a3f5add14be997a28002937629c04d.png)

I hope the example works for you.

---

<div class="post-metadata">

**Author:** ![Dennis1](https://avatars.discourse-cdn.com/v4/letter/d/ecccb3/32.png) [@Dennis1](https://discuss.elastic.co/u/Dennis1)\
**Post date:** [August 21, 2020, 8:43pm UTC](https://discuss.elastic.co/t/alphabetical-sorting-of-numeric-labels-not-working/245940/3 "2020-08-21T20:43:37Z")

</div>

Hi @cheiligers, thank you so much for your quick and helpful reply. What you suggested worked! I didn't think to reorder the timestamp bucket.

For reference, I am running Kibana 7.9.0 as a systemctl service on Ubuntu, installed from the debian package. My mappings for the status code are:

```auto
    "http": {
              "type": "object",
              "properties": {
                "response": {
                  "type": "object",
                  "properties": {
                    "status_code": {
                      "ignore_above": 1024,
                      "type": "keyword"
                    }
                  }
                }
              }
            }

```

Thank you again!

---

<div class="post-metadata">

**Author:** ![cheiligers](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cheiligers/32/73114_2.png) [@cheiligers](https://discuss.elastic.co/u/cheiligers)\
**Post date:** [August 21, 2020, 10:30pm UTC](https://discuss.elastic.co/t/alphabetical-sorting-of-numeric-labels-not-working/245940/4 "2020-08-21T22:30:35Z")

</div>

I'm glad it worked for you!

---

<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:** [September 18, 2020, 10:30pm UTC](https://discuss.elastic.co/t/alphabetical-sorting-of-numeric-labels-not-working/245940/5 "2020-09-18T22:30:47Z")

</div>

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