how to sort API results

astayart
astayart Member Posts: 2

Hi, i am using the infor sx rest api (specifically "sxapioegetlistofordersv4"), and the request includes 2 "sort" fields "sort1" and "sort2" but they don't seem to do anything. Does anyone know how to sort the api results?

thanks.

Best Answer

  • Brandon Watson
    Brandon Watson Member, Infor Partner Posts: 49
    Answer ✓

    Hello - Below are the details for the 2 sort options, for the sxapioegetlistofordersv4. Hopefully this helps.

Answers

  • Carsten Steinhoefel
    Carsten Steinhoefel Member, Staff Posts: 23

    I do not know the SX API specifically so I can't comment on what you might need to pass to those fields to get your output sorted directly.

    What you can do independently of that for any API is to replace the direct call to the SX API with an API flow containing the original API call and a JQ Transform step that sorts the result.

    I assume there is an array of orders in your result. You can then use the sort_by function to sort the array. See https://jqlang.github.io/jq/manual/#sort-sort_by

  • astayart
    astayart Member Posts: 2

    Thanks, this is what i was looking for, and i have one more question, this appears to be a screen shot of some documentation, and i am also looking for other details of the api, is this in a public location i can access? are you able to share a url where i can find this?