TopShelfCraft / TopShelfCraft/SuperSort

Question about sorting by date

Open
#16 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
41
Forks
2
PR merge metrics
No merged PRs in 30d

Description

Hi,

I'm using supersort to try and sort the entries on this page:
https://catrionajeffries.com/artists/valerie-blass/exhibitions

The entries are a combined array of objects. I'm outputting each date into a data attribute on each exhibition:
Screenshot 2023-03-09 at 12 54 05 PM

I would like to order these by most recent date to oldest on the page, but I haven't figured out a way to do this yet.

Have tried various combinations of passing the date into the sort function, but nothing has worked.

{% set sortedExhibitionEntries = combinedExhibitionEntries | supersort('rsortAs', '{exhibitionDate.first.date|date}') %}

{% set sortedExhibitionEntries = combinedExhibitionEntries | supersort('rsortAs', '{{object.exhibitionDate.first.date|date}') %}}

{% set sortedExhibitionEntries = combinedExhibitionEntries | supersort('rsortAs', '{{object.exhibitionDate.date|date}') %}}

I've tried it with and without the date filter, all sorts of other syntax, but it never seems to properly sort by date.

Wondering if anybody might have any insight into the proper syntax here? exhibitionDate does exist for each object, as evidenced by the data attribute in the above screenshot.

Thanks!

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the reported supersort('rsortAs', ...) calls with the combinedExhibitionEntries data and the exhibitionDate values shown in the issue. Read the existing rsortAs behavior and template examples, then confirm a working date-sorting syntax or document the limitation; no source file or test is named.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.