Suppose this is a collection named books in mongodb and the data are as follows.Here I ignore _id. please provide a simple query for finding all books from database where the most costly book's document will comes first.
>{
"name":"A",
"cost":100
}
{
"name":"B",
"cost":1000
}
{
"name":"F",
"cost":400
}
{
"name":"E",
"cost":400
}
{
"name":"Z",
"cost":800
}
My expected result will be:
>{
"name":"B",
"cost":1000
}
{
"name":"Z",
"cost":800
}
{
"name":"E",
"cost":400
}
{
"name":"F",
"cost":400
}
{
"name":"A",
"cost":100
}