Sorting results in v2 doesn't seem to work?

27 views
Skip to first unread message

Josh Adams

unread,
Sep 9, 2025, 7:20:37 PM9/9/25
to apidev
No matter what search I do, or what field I specify in "resultSort" and "resultOrder", it just sorts by the ID key (alphabetically, not numerically).

... "objectType": "animalBreeds", "objectAction": "search", "search": { "resultLimit": 10, "resultSort": "breedName",  "resultOrder": "desc", "filters": [ { "fieldName": "breedSpecies", "operation": "contains", "criteria" : "dog" } ], "fields": ["breedName" ] }


returns:


   "data" : {
      "218" : {
         "breedName" : "Wheaten Terrier"
      },
      "219" : {
         "breedName" : "Whippet"
      },
      "220" : {
         "breedName" : "White German Shepherd"
      },
      "221" : {
         "breedName" : "Wire-haired Pointing Griffon"
      },
      "222" : {
         "breedName" : "Wirehaired Fox Terrier"
      },
      "223" : {
         "breedName" : "Wolf Dog"
      },
      "224" : {
         "breedName" : "Yorkshire Terrier Yorkie"
      },
      "422" : {
         "breedName" : "Yellow Labrador Retriever"
      },
      "424" : {
         "breedName" : "Xoloitzcuintle/Mexican Hairless"
      },
      "964" : {
         "breedName" : "White Swiss Shepherd Dog (Swiss Berger)"
      }
   },


What gives?

Josh

Richard Saffell

unread,
Sep 14, 2025, 9:27:44 AM9/14/25
to apidev, joshb...@gmail.com
Josh,

Pretty sure that's actually your client sorting by the ID field. Look at the raw results from the API to confirm the expected sort.

If you search for your client should should find a way to disable the sorting of the array.

I took your same request and I see the results sorted by breedName:

Screenshot 2025-09-14 092423.png

Josh Adams

unread,
Sep 15, 2025, 3:22:01 PM9/15/25
to apidev, ric...@rescuegroups.org, Josh Adams
Indeed! I was using curl, passing result through json_pp, which apparently is sorting the keys. How embarrassing!

Thanks!
Josh
Reply all
Reply to author
Forward
0 new messages