title: Sort Order of Shopify REST Collections
body: <p>Trying to nail down what the sort order is for Shopify's REST collections.  Specifically I'm working with orders and customers at the moment.</p>
  
  <p>I found this <a href="http://ecommerce.shopify.com/c/ecommerce-design/t/collections-sort-order-3670" rel="nofollow noreferrer">closed thread</a> discussing the ability to sort collections, and the API docs don't mention it at all for either <a href="http://api.shopify.com/order.html" rel="nofollow noreferrer">orders</a> or <a href="http://api.shopify.com/customer.html" rel="nofollow noreferrer">customers</a>.</p>
  
  <p>However, customers have a documented search API, which does have an order parameter as an option.  I'm not sure whether I can use it as a sort of substitute for the regular list API call.  This doesn't seem to work properly for example - it returns more than one result.</p>
  
  <pre><code>/admin/customers/search.json?query=&amp;limit=1
  </code></pre>
  
  <p>Orders don't have a documented search endpoint, but I do get a response when hitting </p>
  
  <pre><code>/admin/orders/search.json?query=&amp;limit=1
  </code></pre>
  
  <p>Although it has the same issues as the customer search endpoint.  I found <a href="https://stackoverflow.com/questions/12318899/shopify-api-get-orders-in-shopify-by-date">this thread</a> saying that orders are always returned most recent to newest by date - and inspecting the response I'm getting now that <em>seems</em> to be true although I could have sworn I've seen them come back in a different orders, it almost seems indeterminate.</p>
  
  <p>Would like to know if that's the case for sure, and the same for customers.  I seem to be getting them returned back in <code>created_at</code> order <em>ascending</em> for customers.  Is that always the case?</p>
  
  <p>Also, ID's for both customers and orders don't seem to be in <code>created_at</code> order, which is bizzare given that the have the <code>since_id</code> parameter in pretty much all their collections (which I found and promptly built my incremental pulling strategy on top of).  I guess I'll have to use <code>created_at</code> instead.</p>