# Custom query from code (sorting issue)

**URL:** <https://forum.builder.io/t/custom-query-from-code-sorting-issue/1921>\
**Category:** Technical Questions\
**Tags:** react\
**Created:** [March 15, 2022, 4:08pm UTC](https://forum.builder.io/t/custom-query-from-code-sorting-issue/1921 "2022-03-15T16:08:01Z")\
**Posts on this page:** 2\
**Page:** 2

<div class="post-metadata">

**Author:** ![spm922](https://avatars.discourse-cdn.com/v4/letter/s/50afbb/32.png) [@spm922](https://forum.builder.io/u/spm922)\
**Post date:** [September 26, 2023, 1:18pm UTC](https://forum.builder.io/t/custom-query-from-code-sorting-issue/1921/22 "2023-09-26T13:18:33Z")

</div>

Sorry to resurrect an old thread! I’m having a similar issue with sorting. I’m trying to query content for a set of conditions and then sort the response alphabetically by a property.

This curl works

```auto
curl -X GET "https://cdn.builder.io/api/v3/content/location?apiKey=67d113c4afd947a7aa749b203e99ace6&query.data.population.$gte=5000&limit=10&sort.data.cityName=1" -H "accept: */*"

```

But this code does not. The response includes the queried data correctly but it is not sorted.

```auto
  const city = await builder.getAll("location", {
    options: {
      sort: {
        'data.cityName': 1
      }
  },
    query: {
      data: {
        population: { $gte: 50000 },
        stateAbbreviation: { $regex: params.state, $options: "i" }
      },
    },
  })

```

What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![spm922](https://avatars.discourse-cdn.com/v4/letter/s/50afbb/32.png) [@spm922](https://forum.builder.io/u/spm922)\
**Post date:** [September 26, 2023, 7:53pm UTC](https://forum.builder.io/t/custom-query-from-code-sorting-issue/1921/23 "2023-09-26T19:53:24Z")

</div>

I was using v2 react SDK. Updating to latest fixed the sorting issue.

[Previous page](https://forum.builder.io/t/custom-query-from-code-sorting-issue/1921.md?page=1)
