Recently added items in a collection are not correctly ordered from newest to oldest

Hi guys. I hope somebody can help me.
Recently added items in a collection are not correctly ordered from newest to oldest. I checked, and what happens is this: the date ordering it uses is 1/1/2000 > 20/1/2000. Because it is an alphabetical order and does not include zeros.
How can I correct that?


Because it is in Spanish, the date order is dd/mm/yyyy.

Are you using anything else that would affect the order of the items in the collection? The Item Order plugin?

The sorting here takes place on the dates in the database and doesn’t/shouldn’t vary based on the configured locale and how it displays dates.

Hi jflatnes! No, I don’t use that plugin. Apart from plugins like Stats and that type, I only use Collection Tree. Indeed in the database it is correctly.
If you could guide me on which files to look at… those with the functions or builds that order the elements in the collections, I’ll look line by line to see if I can find the error.
By way of illustration, here you can see, on the right, the (incorrect) order that it generates in the collections:

But when entering to see all the elements of the collection, the order is correct.

OK, I think the problem here is pretty simple: the code for printing items in the collection on the show page doesn’t actually ask for the most recent ones, it just asks for a page of items while specifying no order. (If you’re curious, this code lives in application/controllers/CollectionsController.php in the showAction method.)

Sometimes this means you get them in order by most recent, but sometimes not: the database is free to give us any 10 (or whatever) items. A small change to this code to actually request the items in order by added date should fix the display so the items shown are in the same order as if you chose that order on the browse page.

Thanks very much. I will try fix that!

If you’re looking to fix this, the fix should look like adding

'sort_field' => 'added', 'sort_dir' => 'd'

to the array on line 32 that currently just contains collection.