The client has a large number of ‘Product Offer’ components which they need fetched so I wrote a wrapper to the CD API to allow the fetching of these offers by metadata, more specifically by metadata fields and values passed in as a HashMap. They requested that we sort the returned Component Presentations based on a custom metadata field called ‘Priority’, which of course is no problem. We could simply call addSorting on the query object passing in a new sortParameter and sort them by their literal String values such as below.
CustomMetaKeyColumn customMetaKeyPriority = new CustomMetaKeyColumn(metadataField, MetadataType.STRING); query.addSorting(new SortParameter(customMetaKeyPriority, SortParameter.ASCENDING));
However, when there is a conflict (for instance we are returned the top 5 CPs with highest priority) we want the Component Presentations sorted by their last modification date so we get the most recently updated. Is there any way that I can apply multiple sort parameters so that when we run into priority conflicts, we can resolve these conflicts using another sort parameter?
Note that I found this answer ‘https://stackoverflow.com/questions/11228580/applying-more-than-one-sort-on-a-tridion-broker-query’, but it did definitively answer my question.