How to sort json file ascending in pymongo?

0 votes
I want to sort json file Ascending or Descending after connect on pymongo, and I have this problem ...

when is use this code :

db.data.find()

or this code :

cars = db.cars.find().sort("price", DESCENDING)

I got this message :

<pymongo.cursor.Cursor object at 0x7f4b50315890>
Aug 14 in Python by Ahmed
• 310 points
64 views

1 answer to this question.

0 votes

Hey Ahmad, you can get the output by iterating over your curser.

for row in cars
    print(row)
answered Aug 14 by Trisha