# Kibana 8.7 Control Sort

**URL:** https://discuss.elastic.co/t/kibana-8-7-control-sort/329758
**Category:** Kibana
**Created:** [April 11, 2023, 2:59pm UTC](https://discuss.elastic.co/t/kibana-8-7-control-sort/329758 "2023-04-11T14:59:05Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Jonas\_S](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jonas_s/32/97631_2.png) [@Jonas\_S](https://discuss.elastic.co/u/Jonas_S)
#### Post date: [April 11, 2023, 2:59pm UTC](https://discuss.elastic.co/t/kibana-8-7-control-sort/329758/1 "2023-04-11T14:59:06Z")

</div>

Hello,

i just checked out the new sorting functionallity for controls.

- The default setting is to sort desc by doc count  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/3/b/3b1d884b471f1cec09bd6815e56f32f417fc9a30.png)  
I want asc alphabetically on every control. How can i change that in an easy way? I could not find a new setting related to this.  
Or do i have to go through every control and change it and save the dashboard afterwards? Will this even work or is this user specific? I know it works for the selection, so if i edit a dashboard and select anything in the control and save the dashboard afterwards, if another user opens the dashboard everytime this selections is in by default. Is it the same behaviour with the sort setting?
- On some controls it does not work at all and i can't figure out why:  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/6/6/66050eed113d5c27a75c44b919aee1ee7e586435.png)  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/b/a/ba72d2d122f848887991143ad28a5e2e33615579.png)
- Usually the control is closed, if another one is selected. Although if the sort menu is open, only the submenu gets closed and not everything. This can result in this:  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/3/6/365f569137cc1e4ce9c9854ae3ca4773499b96e5.png)  
A lot of opened control menues and from there every time you click on a control one extra window gets closed at a time. Looks like unintentional behaviour to me

Best regards  
Jonas

---

<div class="post-metadata">

### Author: ![Jonas\_S](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jonas_s/32/97631_2.png) [@Jonas\_S](https://discuss.elastic.co/u/Jonas_S)
#### Post date: [April 13, 2023, 10:04am UTC](https://discuss.elastic.co/t/kibana-8-7-control-sort/329758/2 "2023-04-13T10:04:43Z")

</div>

Another example of the alphabetical sort not working:  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/d/6/d6c2fc8d32bf329726f46e3a4f91aa0be68a0f87.png)  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/3/9/39cf5136bcf70d1acccd2d1ccb1c02c7bde1e57e.png)

---

<div class="post-metadata">

### Author: ![Hannah\_Mudge](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hannah_mudge/32/107993_2.png) [@Hannah\_Mudge](https://discuss.elastic.co/u/Hannah_Mudge)
#### Post date: [April 17, 2023, 3:22pm UTC](https://discuss.elastic.co/t/kibana-8-7-control-sort/329758/3 "2023-04-17T15:22:38Z")

</div>

> I want asc alphabetically on every control. How can i change that in an easy way? I could not find a new setting related to this. Or do i have to go through every control and change it and save the dashboard afterwards? Will this even work or is this user specific?

You do currently have to go to each control to set the default sort - after all, we support fields that don't support alphabetical sorting (for example, IP fields) and we have a range slider control that don't support the concept of sorting **at all** , so having it be a control group setting would be inconsistent and confusing.

> I know it works for the selection, so if i edit a dashboard and select anything in the control and save the dashboard afterwards, if another user opens the dashboard everytime this selections is in by default. Is it the same behaviour with the sort setting?

Yes! If you select the sort in edit mode and then save the changes, this will be the default for everyone who opens the dashboard in view mode - we did this so that authors can choose the sorting technique that makes the most sense for a given field.

> On some controls it does not work at all and i can't figure out why:

That is because that is a `keyword` type field, and so it is still sorting **alphabetically** (i.e. it is using "string sort" logic) and not **numerically**. We currently don't have support for numeric fields for options list controls, but you can track that enhancement [here](https://github.com/elastic/kibana/issues/126795).

> Usually the control is closed, if another one is selected. Although if the sort menu is open, only the submenu gets closed and not everything. This can result in this:

Looks like you caught a bug there - good catch! I'll file an issue 🙂

**Edit:** You can track this bug [here](https://github.com/elastic/kibana/issues/155059).

---

<div class="post-metadata">

### Author: ![Jonas\_S](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jonas_s/32/97631_2.png) [@Jonas\_S](https://discuss.elastic.co/u/Jonas_S)
#### Post date: [April 17, 2023, 3:40pm UTC](https://discuss.elastic.co/t/kibana-8-7-control-sort/329758/4 "2023-04-17T15:40:34Z")

</div>

> [@Hannah\_Mudge](#):
>
> That is because that is a `keyword` type field, and so it is still sorting **alphabetically** (i.e. it is using "string sort" logic) and not **numerically**. We currently don't have support for numeric fields for options list controls, but you can track that enhancement [here](https://github.com/elastic/kibana/issues/126795).

Good to see progress there. That's why i need to cast all my numbers to strings, so i can use controlls for them. But even if a string sort logic is used it should be 1 2 3 in asc and 3 2 1 in desc. Not 1 2 3 for both.  
I understand that 1, 2, 10 would be sorted to 1 10 2 asc and 2 10 1 desc, but not 1 10 2 for both directions.

---

<div class="post-metadata">

### Author: ![Hannah\_Mudge](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hannah_mudge/32/107993_2.png) [@Hannah\_Mudge](https://discuss.elastic.co/u/Hannah_Mudge)
#### Post date: [April 17, 2023, 4:30pm UTC](https://discuss.elastic.co/t/kibana-8-7-control-sort/329758/5 "2023-04-17T16:30:35Z")

</div>

@Jonas_S Oh boy! Took a little while, but turns out you found a pretty sneaky little bug that is causing sorting to misbehave because of how we are storing the suggestions - the results from the ES query we are firing to grab the suggestions returns the values in the expected order, but we are parsing + storing the results in an object and Javascript is doing its own sorting based on the keys of that object. So you get some pretty weird results - good catch!

You can track this issue [here](https://github.com/elastic/kibana/issues/155073) 👍

---

<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: [May 15, 2023, 4:31pm UTC](https://discuss.elastic.co/t/kibana-8-7-control-sort/329758/6 "2023-05-15T16:31:21Z")

</div>

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