I can't orderings by array

I using Gatsby and prismic-javascript.
I want to order by 2 values. But it doesn't work correctly

Hi @winth ,

Welcome to the community!

So, the first thing I noticed is that you're ordering by blog.data.order_number

If you check our documentation...

You'll see that the syntax is my.[custom-type].[field].

So, in your case, it should be my.blog.order_number. Test this and let me know how you get on.


Hi @Phil ,
Thanks for your support.
I use my.blog.order_number, but it is still incorrect.
For example:

  • 1st priority: order number. For example, a post with order number 1st is displayed in the 1st position
  • 1st publication: the post with the order number field blank will be sorted by 1st publication date.

I can't order by 2 values.

Hi @Phil,
and another question, it throws an error when I use my.blog.order_number asc, if I don't have asc it is response incorrectly

FYI: prismic-javascript package version: 3.0.2

Hi @Phil,
Can you help me resolve my problem?

I'm wondering...
I know the docs say that orderings can be an array, but I've always had luck with using an object. Here's my example:

* The code below grabs products of a specific brand based on the slug (uid)
* and sorts them by ascending by their title 
if (page.type === 'brand') {
    const products = await client.getAllByType('product', {
      graphQuery: `
          product {
      filters: [prismic.filter.at('my.product.brand', page.id)], 
      orderings: {
        field: 'my.product.title',
        direction: 'asc',

Hope that helps some.

With Gatsby, you can sort your results in a different way, which might work better for you here: