# Array of dates always sorts ascending in Kibana Discovery Query results

**URL:** https://discuss.elastic.co/t/array-of-dates-always-sorts-ascending-in-kibana-discovery-query-results/56311
**Category:** Kibana
**Created:** [July 25, 2016, 3:37pm UTC](https://discuss.elastic.co/t/array-of-dates-always-sorts-ascending-in-kibana-discovery-query-results/56311 "2016-07-25T15:37:08Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Bullwinkle](https://avatars.discourse-cdn.com/v4/letter/b/8491ac/32.png) [@Bullwinkle](https://discuss.elastic.co/u/Bullwinkle)
#### Post date: [July 25, 2016, 3:37pm UTC](https://discuss.elastic.co/t/array-of-dates-always-sorts-ascending-in-kibana-discovery-query-results/56311/1 "2016-07-25T15:37:08Z")

</div>

I have documents which contain an ES login-history field, and the ES documents have the login history in reverse chronological order. The problem I have is that Kibana always presents the dates in ascending order when if the date field is in the selected query attributes, or in the 'Table' view of a record. If I click the JSON view things look fine, e.g.:

"login-history": [  
1464884262941,  
1464877491523,  
1464876396375,  
1464802504594,  
1464276153017,  
1464275650052,  
1464275616108,  
1464275192750,  
1464270502451,  
1464201004285  
]

But when printed any other way in query results (TABLE record view, query results), they appear this way:

May 25th 2016, 14:30:04.285, May 26th 2016, 09:48:22.451, May 26th 2016, 11:06:32.750, May 26th 2016, 11:13:36.108, May 26th 2016, 11:14:10.052, May 26th 2016, 11:22:33.017, June 1st 2016, 13:35:04.594, June 2nd 2016, 10:06:36.375, June 2nd 2016, 10:24:51.523, June 2nd 2016, 12:17:42.941

How can I get Kibana (Version 4.5) to present the data as it is ordered in the record instead of reordering the data when it formats the dates?

---

<div class="post-metadata">

### Author: ![tsullivan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tsullivan/32/31077_2.png) [@tsullivan](https://discuss.elastic.co/u/tsullivan)
#### Post date: [July 25, 2016, 7:42pm UTC](https://discuss.elastic.co/t/array-of-dates-always-sorts-ascending-in-kibana-discovery-query-results/56311/2 "2016-07-25T19:42:29Z")

</div>

I can reproduce this with this data, that I set up in Sense:

```auto
PUT /bullwinkle
{
  "settings": {
    "number_of_replicas": 0,
    "number_of_shards": 1
  }
}

PUT /bullwinkle/type1/_mapping
{
  "properties": {
    "name": {
      "type": "string"
    },
    "login_history": {
      "type": "date"
    }
  }
}

// login_history reverse order
POST /bullwinkle/type1/1
{
  "name": "First post",
  "login_history": [
    1464884262941,
    1464877491523,
    1464876396375,
    1464802504594,
    1464276153017,
    1464275650052,
    1464275616108,
    1464275192750,
    1464270502451,
    1464201004285
  ]
}

// _source has the login_history values in the right order
GET /bullwinkle/type1/1

```

And Kibana shows the array data sorted when it's displayed in the doc table. It doesn't seem to matter what the mapping for the `login_history` field is, and there doesn't seem to be any place in Advanced settings that can control this.

This is odd behavior, it might be a bug. I see this happen in Kibana 4.x and Kibana 5.

---

<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, 1:44pm UTC](https://discuss.elastic.co/t/array-of-dates-always-sorts-ascending-in-kibana-discovery-query-results/56311/3 "2017-07-06T13:44:16Z")

</div>


