# Sorting cross several fields

**URL:** <https://discuss.elastic.co/t/sorting-cross-several-fields/90462>\
**Category:** Elasticsearch\
**Created:** [June 22, 2017, 1:22pm UTC](https://discuss.elastic.co/t/sorting-cross-several-fields/90462 "2017-06-22T13:22:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![superodd](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/superodd/32/19419_2.png) [@superodd](https://discuss.elastic.co/u/superodd)\
**Post date:** [June 22, 2017, 1:22pm UTC](https://discuss.elastic.co/t/sorting-cross-several-fields/90462/1 "2017-06-22T13:22:44Z")

</div>

In my index, if I have records that looks something like this:

```
{
    "date1": "<someDate>",
    "date2": "<someOtherDate>"
}

```

Is it possible to make a sort that gives me the documents in order accross the "date1" and "data2" fields?

For instance, if I have these records:

```
1: {"date1": "1950-01-01",
    "date2": "2000-01-01"}

2: {"date1": "1960-01-01",
     "date2": "1951-01-01"}

3: {"date1": "1970-01-01",
     "date2": "1950-02-02"}

```

The order I want to receive them in should be 1,3,2 because 1 has the the earliest date in the date1 field, then 3 has the next one in the date2 field, and then 2 in the date2 field.

Thanks!

---

<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 20, 2017, 1:23pm UTC](https://discuss.elastic.co/t/sorting-cross-several-fields/90462/2 "2017-07-20T13:23:19Z")

</div>

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