# How to sort the data in Logstash?

**URL:** <https://discuss.elastic.co/t/how-to-sort-the-data-in-logstash/255628>\
**Category:** Logstash\
**Created:** [November 17, 2020, 7:07am UTC](https://discuss.elastic.co/t/how-to-sort-the-data-in-logstash/255628 "2020-11-17T07:07:56Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![yummycake](https://avatars.discourse-cdn.com/v4/letter/y/2acd7d/32.png) [@yummycake](https://discuss.elastic.co/u/yummycake)\
**Post date:** [November 17, 2020, 7:07am UTC](https://discuss.elastic.co/t/how-to-sort-the-data-in-logstash/255628/1 "2020-11-17T07:07:56Z")

</div>

I have ingested the data from CSV into Elasticsearch, however, when I view them in 'Discover, Kibana' the ID did not ingest in order.

The field 'ID' in the CSV doc starts from 1

For example, instead of:  
1  
2  
3  
4

It was ingested like this:  
4  
2  
1  
3

Here is my logstash.conf

```auto
 filter {
   csv {
    separator => ","
    columns => ["ID","Title","Grant ($)"]
}

```

Is there any way I can sort this out (no pun intended)?

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [November 17, 2020, 7:16am UTC](https://discuss.elastic.co/t/how-to-sort-the-data-in-logstash/255628/2 "2020-11-17T07:16:52Z")

</div>

Not in Logstash.

Did you sort by the ID field in Kibana?

---

<div class="post-metadata">

**Author:** ![yummycake](https://avatars.discourse-cdn.com/v4/letter/y/2acd7d/32.png) [@yummycake](https://discuss.elastic.co/u/yummycake)\
**Post date:** [November 17, 2020, 7:29am UTC](https://discuss.elastic.co/t/how-to-sort-the-data-in-logstash/255628/3 "2020-11-17T07:29:03Z")

</div>

Hi @warkolm! My ID is in strings. I am not sure how to do the sort in Kibana though.

Any help?

Is it something like this

```auto
POST/my_index/
{
    "sort" : [
        { "ID" : {"order" : "asc"}}

```

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [November 17, 2020, 7:30am UTC](https://discuss.elastic.co/t/how-to-sort-the-data-in-logstash/255628/4 "2020-11-17T07:30:24Z")

</div>

If you click on the column header you can sort.

---

<div class="post-metadata">

**Author:** ![yummycake](https://avatars.discourse-cdn.com/v4/letter/y/2acd7d/32.png) [@yummycake](https://discuss.elastic.co/u/yummycake)\
**Post date:** [November 17, 2020, 7:37am UTC](https://discuss.elastic.co/t/how-to-sort-the-data-in-logstash/255628/5 "2020-11-17T07:37:39Z")

</div>

I believe I have to convert the ID to integer to make this work?

---

<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:** [December 15, 2020, 7:37am UTC](https://discuss.elastic.co/t/how-to-sort-the-data-in-logstash/255628/6 "2020-12-15T07:37:39Z")

</div>

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