Skip to main content
Reference

Sorting Results

Methods that allow for more than one object to be returned generally supply a _sort parameter that lets you specify the order in which the results are returned. For example, orders can be sorted by the following fields:

  • order_id
  • shipping.company
  • shipping.first_name
  • shipping.last_name
  • shipping.city
  • shipping.state_region
  • shipping.postal_code
  • shipping.country_code
  • billing.phone
  • billing.email
  • billing.cc_email
  • billing.company
  • billing.first_name
  • billing.last_name
  • billing.city
  • billing.state
  • billing.postal_code
  • billing.country_code
  • creation_dts
  • payment.payment_dts
  • checkout.screen_branding_theme_code
  • channel_partner.channel_partner_code
  • channel_partner.channel_partner_order_id

As with most data-set sorting routines, there is an ascending and a descending option. So to sort the result set by billing last name (ascending) followed by billing first name (ascending), you would use the following _sort parameter:

+billing.first_name,+billing.last_name

If you wanted to find the most recent orders, then you would sort by creation_dts in a descending fashion with:

-creation_dts
warning

Always URL-encode parameters! If you fail to URL-encode the plus character, you are going to receive a bad request error for an improper sort attribute.

Was this page helpful?