# Sort string versions in kibana

**URL:** <https://discuss.elastic.co/t/sort-string-versions-in-kibana/235698>\
**Category:** Kibana\
**Created:** [June 4, 2020, 8:10am UTC](https://discuss.elastic.co/t/sort-string-versions-in-kibana/235698 "2020-06-04T08:10:41Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Angelos](https://avatars.discourse-cdn.com/v4/letter/a/4bbf92/32.png) [@Angelos](https://discuss.elastic.co/u/Angelos)\
**Post date:** [June 4, 2020, 8:10am UTC](https://discuss.elastic.co/t/sort-string-versions-in-kibana/235698/1 "2020-06-04T08:10:41Z")

</div>

Elastic/Kibana version: 7.7(Platinum)  
Hi,

In my case I have version fields that look like that "NAME-10.1.0" or "NAME-10.1.1\_beta".  
So when I sort them in a visualisation(Histogram), they are sorted like this:

> NAME-20.19.2  
> NAME-20.19.3\_alpha  
> NAME-20.19.4  
> **NAME-20.2.0** (This should be way up)  
> NAME-20.20.0\_alpha  
> NAME-20.20.1\_beta

Is there any way to sort string versions correctly?

/Angelos

---

<div class="post-metadata">

**Author:** ![majagrubic](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/majagrubic/32/74459_2.png) [@majagrubic](https://discuss.elastic.co/u/majagrubic)\
**Post date:** [June 4, 2020, 10:02am UTC](https://discuss.elastic.co/t/sort-string-versions-in-kibana/235698/2 "2020-06-04T10:02:34Z")

</div>

I'm not sure why you think `NAME-20.2.0` should be way up. The names are sorted in a lexicographic order, not semantical.

I made a small JSFiddle to show this is indeed how native Javascript sort method works:  
[https://jsfiddle.net/#run&togetherjs=prMnyzRM0S](https://jsfiddle.net/#run&togetherjs=prMnyzRM0S)

---

<div class="post-metadata">

**Author:** ![Angelos](https://avatars.discourse-cdn.com/v4/letter/a/4bbf92/32.png) [@Angelos](https://discuss.elastic.co/u/Angelos)\
**Post date:** [June 4, 2020, 11:52am UTC](https://discuss.elastic.co/t/sort-string-versions-in-kibana/235698/3 "2020-06-04T11:52:31Z")

</div>

Hi,

Thank you for your response.  
So, we have to change the way we index this field.

/Angelos

---

<div class="post-metadata">

**Author:** ![majagrubic](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/majagrubic/32/74459_2.png) [@majagrubic](https://discuss.elastic.co/u/majagrubic)\
**Post date:** [June 4, 2020, 12:37pm UTC](https://discuss.elastic.co/t/sort-string-versions-in-kibana/235698/4 "2020-06-04T12:37:17Z")

</div>

What is your use-case? Would you simply like to see this sorted in a descending order?

---

<div class="post-metadata">

**Author:** ![Angelos](https://avatars.discourse-cdn.com/v4/letter/a/4bbf92/32.png) [@Angelos](https://discuss.elastic.co/u/Angelos)\
**Post date:** [June 4, 2020, 2:01pm UTC](https://discuss.elastic.co/t/sort-string-versions-in-kibana/235698/5 "2020-06-04T14:01:48Z")

</div>

I want semantic version sorting(ascending), so it will look like that:

> **NAME-20.2.0**  
> NAME-20.2.1  
> NAME-20.2.2  
> NAME-20.2.3  
> NAME-20.2.4  
> NAME-20.3.0  
> NAME-20.3.1  
> .  
> .  
> .  
> NAME-20.19.2  
> NAME-20.19.3\_alpha  
> NAME-20.19.4  
> NAME-20.20.0\_alpha  
> NAME-20.20.1\_beta

/Angelos

---

<div class="post-metadata">

**Author:** ![majagrubic](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/majagrubic/32/74459_2.png) [@majagrubic](https://discuss.elastic.co/u/majagrubic)\
**Post date:** [June 5, 2020, 9:59am UTC](https://discuss.elastic.co/t/sort-string-versions-in-kibana/235698/6 "2020-06-05T09:59:33Z")

</div>

Yes, for that the best would be to store the versions in a separate field in ES.

---

<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 3, 2020, 9:59am UTC](https://discuss.elastic.co/t/sort-string-versions-in-kibana/235698/7 "2020-07-03T09:59:51Z")

</div>

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