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, 2019 in Python by Ahmed
• 310 points
911 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, 2019 by Trisha

Related Questions In Python

0 votes
1 answer

How to order_by a JSON from serializers.py file in django rest framework?

Hello @kartik, There's an easy way, just override ...READ MORE

answered Jul 2, 2020 in Python by Niroj
• 82,880 points
5,661 views
+1 vote
1 answer