Hi Everyone, I was hoping somebody might be able to solve a problem I'm having attempting to implement a view at the moment. Essentially, what it does is to take a collection of documents which each have a single author and a list of names (which a possibly repeated). There may be multiple documents by the same author, with the same names within. Here's an example doc. doc.author doc.titles = ['sometitle', 'someothertitle', 'sometitle, 'anothertitle'] I would like to return a list of the top 3 titles across for each author across all documents. I have tried and failed for several days to get this working correctly. So far, my map is as follows, giving the unique titles for a document, not ordered at all: function(doc) { var unique_titles = []; for(var i in doc.titles) { var count=0; for(var j in unique_titles) { if(doc.titles[i]==unique_titles[j]) { count++; } } if(count==0) { unique_titles.push(doc.titles[i]); } } for(var k=0; k