sorting elasticsearch top hits results
<p>I am trying to execute a query in elasticsearch to get reuslt of specific users from certain date range. the results should be grouped by userId and sorted on trackTime field, I am able to use group by using aggregation but i am not able to sort aggregation buckets on tracktime, i write down the following query</p>

<pre><code>GET _search
{
"size": 0,
"query": {
    "filtered": {
        "query": {
            "bool": {
                "must": [
                    {
                        "range": {
                            "trackTime": {
                                "from": "2016-02-08T05:51:02.000Z"
                            }
                        }
                    }
                ]
            }
        },
        "filter": {
            "terms": {
                "userId": [
                    9,
                    10,
                    3
                ]
            }
        }
    }
},
"aggs": {
    "by_district": {
        "terms": {
            "field": "userId"
        },
        "aggs": {
            "tops": {
                "top_hits": {
                    "size": 2
                }
            }
        }
    }
}
 }
</code></pre>

<p>what more should i have to use to sort the top hits result? Thanks in advance... </p>