Is there a way to sort a reference column?

Hey Phil,

Currently, there isn’t a simple way to sort by Reference field, but you can code a workaround by adding field value from referenced collection into separate column that will be filterable. Your code might look something like this:

import wixData from 'wix-data'

export function CollectionWithReference_beforeUpdate(item, context) {
    // Get id regardless of whether you're adding the item through site or Content Manager 
    const referencedItemId = item.referenceField._id || item.referenceField
    
    // Get data from referenced collection
    return wixData.get('RefCollection', referencedItemId)
        .then(ref => {
            // Add value that you'll use to filter your collection
            item.filterableField = ref.fieldToUseForFilter
            return item
        })
}

And lastly, you can easily sort Dataset by field Last Updated.

Hope that helps!