How is Prismic sorting documents by a string field?

Hello Prismic Team, how is Prismic sorting documents by a string field?

I've tested two documents having title field (it's a Key Text field) Test4Content Page and Test Content Page. When I request Prismic for them to be sorted alphabetically by the title in ascending order I get Test4Content Page before Test Content Page, while I would expect the other way around. :thinking:

It triggers me to another question - what if the key text field contains international characters? What is the sorting order?

I have more information for my question. When I sort only by the title then I get document sorted as expected: Test Content Page before Test4Content Page.

In the case I mentioned in the previous post documents were sorted by a custom date field and the title. Both documents have the same value of the date 2020-09-15 so the sequence of the documents should be the same as with sorting only by the title but it's not.

Could you explain this to me, pls?

Hello marek,

Thanks for posting us.

Unfortunately, at the moment there is no way to arrange the order of the Prismic document list alphabetically (or any other way).
We use last update time or date to arrange the document list. It means you will get the most recently published documents at the top and the oldest at the end of the list.

I will let the @features-team know about this and we will add this to our feature request tracker as a possible improvement for the future.

Meanwhile, you can use Collections to filter and find documents. Here is a guide.

Thanks,
Priyanka

Hi Priyanka,

I don't understand. There is the orderings parameters for that purpose described in your documentation https://prismic.io/docs/technologies/order-your-results-rest-api

Are you saying it's not working?

Hi Marek,

Sorry, I misunderstood your question. Can you please explain more on the example where your sorting is not working? Because I tested with the following case:

I have 2 documents with title and date field:

  1. Title: Peace on earth, Date: 11-24-2020
  2. Title: Computers science, Date: 11-24-2020

And when I sort by giving orderings [my.page.date,my.page.title], it works by giving results like

  1. Title: Computers science, Date : 11-24-2020
  2. Title: Peace on earth, Date : 11-24-2020

And it works.

And question of sorting order in case of international character, I'm following up with my dev team. I'll come back to you on this when I hear anything from them.

Thanks,
Priyanka

Hi, Priyanka,

Preparing to respond to you I realized that Test Content Page and Test4Content Page actually don't have the same publishing_date :man_facepalming: I'm sorry. It must have been my mistake apparently. Sorting works.

The question about international characters remains valid. Please, try to find the answer. Thanks