What is best practice for applying a custom sort function to a collection (something that goes beyond
defaultSort)? I thought I'd be able to use a collection hook here but looks like there are no hooks that have access to the entire
docsarray. Our immediate goal is to set a specific order for a related field drop down options.
Also tried a custom endpoint, but doesn't seem like that affects the local API
Hi Seth!
beforeReadhas access to
docwhich will be the collection of docs you're looking for. You can apply your sort logic there and return the sorted result.
Star
Discord
online
Get dedicated engineering support directly from the Payload team.