I have a collection in mongo which has name and count fields.
{name:\'myName\',count:5}
Is it possible to sort data by count and export as json
Actually you can, but you have to use special params. Here's a sample (redirecting to file):
$ mongoexport -q '{ $query: {count: {$gt:0}}, $orderby: {count: -1} }' -d database -c collection > data_dump.json
The $query part is not strictly necessary, but I included it because of this bug on GitHub (fixed now, but only just).