Spring-Data MongoDB MapReduce Sort output
<p>I have something like:</p>

<pre><code>mongoTemplate.mapReduce("myCollection", MAP_FUNC, REDUCE_FUNC, KeyValuePair.class);
</code></pre>

<p>Then the result looks like:</p>

<pre><code>[
{id: "1", count: 5},
{id: "2", count: 20},
{id: "3", count: 9},
{id: "4", count: 3}
]
</code></pre>

<p>How can I <code>sort</code> this array like:</p>

<pre><code>[

{id: "2", count: 20},
{id: "3", count: 9},
{id: "1", count: 5},
{id: "4", count: 3}
]
</code></pre>

<p>and after that <code>limit</code> result to <code>5</code>.</p>

<p>There is a <code>sort</code> option in MongoDB mapReduce, but I cannot find it in class <code>org.springframework.data.mongodb.core.mapreduce.MapReduceOptions</code> from Spring Data MongoDB. </p>