How To Sort Data Using PyMongo

Praveen Singh         No comments

This is going to be a simple programme to sort data in Pymongo ( MongoDB + Python).

I am using Pycharm as my IDE. I have already covered how to install Pycharm in my previous post.

So, you already know how to insert data in MongoDB.

Structure :

Database name : school
Collection         : students

Just 5 lines code to sort data !!!

from pymongo import MongoClient

conn= MongoClient()

db =

col= db.students

for item in col.find().sort([('name',1)]):
    print (item['name'])

Output at the bottom....

Published by Praveen Singh

A blogger by passion.You can find me tucked in my bed and blogging on weekends when not roaming around. Besides blogging, I love music and you can find my songs on my fb page:PraveenUnplugged
Follow on Youtube : Videos On Latest Happenings |ThingsToKnow
Follow us Talend In Action

0 responses:

© 2015 Techie's House. Designed by Bloggertheme9