# Sort descending with JavaScript API

**URL:** <https://discuss.elastic.co/t/sort-descending-with-javascript-api/17861>\
**Category:** Elasticsearch\
**Created:** [June 2, 2014, 4:12pm UTC](https://discuss.elastic.co/t/sort-descending-with-javascript-api/17861 "2014-06-02T16:12:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![el1](https://avatars.discourse-cdn.com/v4/letter/e/b9bd4f/32.png) [@el1](https://discuss.elastic.co/u/el1)\
**Post date:** [June 2, 2014, 4:12pm UTC](https://discuss.elastic.co/t/sort-descending-with-javascript-api/17861/1 "2014-06-02T16:12:13Z")

</div>

This is a syntax question. In my search I want to sort descending on a  
field named 'no'. I tried things like params.sort = "no: {order: 'desc'}"  
or params.sort = "[{'no': {'order': 'desc'}}]" but nothings works. If I  
just specify params.sort = "no" the ascending sort works fine. Can somebody  
give me a hint please?

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/b26ebaad-827f-47d4-b328-51e9ece016c1%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/b26ebaad-827f-47d4-b328-51e9ece016c1%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![ElasticSearch\_Users\_](https://avatars.discourse-cdn.com/v4/letter/e/b4bc9f/32.png) [@ElasticSearch\_Users\_](https://discuss.elastic.co/u/ElasticSearch_Users_)\
**Post date:** [June 2, 2014, 7:11pm UTC](https://discuss.elastic.co/t/sort-descending-with-javascript-api/17861/2 "2014-06-02T19:11:37Z")

</div>

Can you try:

```
client.search({
  body: q,
  sort: "no:desc"
});

```

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/63bef7a5-63c8-4d2b-92c0-b27c3157b18e%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/63bef7a5-63c8-4d2b-92c0-b27c3157b18e%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![el1](https://avatars.discourse-cdn.com/v4/letter/e/b9bd4f/32.png) [@el1](https://discuss.elastic.co/u/el1)\
**Post date:** [June 3, 2014, 1:54pm UTC](https://discuss.elastic.co/t/sort-descending-with-javascript-api/17861/3 "2014-06-03T13:54:21Z")

</div>

Great, this works. Thanks a lot.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/c171f577-2d60-42de-82e0-bec45e2c4921%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/c171f577-2d60-42de-82e0-bec45e2c4921%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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:24am UTC](https://discuss.elastic.co/t/sort-descending-with-javascript-api/17861/4 "2017-07-06T01:24:56Z")

</div>


