I need to sort the results by several fields.
In my case, first sort by year, then by month. The year and month field is included in my own content type ( item_publication_year and item_publication_month respectively).
However, I do not get the results that I want. Year and month are not ordered at all. They should appear in descending order, i.e. 2006, 2005, 2004, etc.
Below is my code:
def queryItemRepository(self): """ Perform a search returning items matching the criteria """ query = {} portal_catalog = getToolByName(self, 'portal_catalog') folder_path = '/'.join( self.context.getPhysicalPath() ) query['portal_type'] = "MyContentType" query['path'] = {'query' : folder_path, 'depth' : 2 } results = portal_catalog.searchResults(query)
Can anybody help?
source share