Problem with pagination bar

I have created a list of content in the Content Manager, where I label the title for each content as Psalm 1, Psalm 2, …Psalm 10.

I have created a pagination bar to connect to this database. However, when I click on “2”, it goes to Psalm 10 instead of Psalm 2.

When I click on “2” on the pagination bar, it should go to Psalm 2, not Psalm 10.
How to solve this problem?

Most likely your problem is a result of the alphabetic (or lexicographical) sort behavior. If you are sorting by title, then, the order will be: Psalm 1, Psalm 10, Psalm 11, … Psalm 2.

For a quickie demonstration, I created a page with a Repeater and a Dataset. I connect the dataset to a database collection with the Psalms as titles. I then added Repeater to the page and connected the text field to the Title field. I set the sort to ascending. Here’s is my code:

import wixData from 'wix-data';

$w.onReady(() => {
    $w("#dataset1").onReady(() => {
        $w("#dataset1").setSort(wixData.sort()
            .ascending("title")
        );
    });
});

And, here is the result in the Repeater:

What you can do is to add a number field to the database collection on which you can perform a numeric sort.

Here is the code with a sort on the order column.

$w.onReady(() => {
    $w("#dataset1").onReady(() => {
        $w("#dataset1").setSort(wixData.sort()
            .ascending("order")
        );
    });
});

And here is the resulting display:

It’s a miracle. :beers: