sort
should be a list of key-direction pairs, that is
db.test.find({"number": {"$gt": 1}}).sort([("number", 1), ("date", -1)])
The reason why this has to be a list is that the ordering of the arguments matters and dict
s are not ordered in Python < 3.6
Related Contents:
- How to import data from mongodb to pandas?
- Query Mongodb on month, day, year… of a datetime
- search by ObjectId in mongodb with pymongo
- How to sort mongodb with pymongo
- Insert a Pandas Dataframe into mongodb using PyMongo
- How to Ignore Duplicate Key Errors Safely Using insert_many
- Getting Spark, Python, and MongoDB to work together
- How to convert a pymongo.cursor.Cursor into a dict?
- Fast or Bulk Upsert in pymongo
- How to make a query date in mongodb using pymongo?
- Append item to MongoDB document array in PyMongo without re-insertion
- “Large data” workflows using pandas [closed]
- TypeError: ObjectId(”) is not JSON serializable
- mongodb: insert if not exists
- Pymongo keeps refusing the connection at 27017
- Why is PyMongo 3 giving ServerSelectionTimeoutError?
- JSON ValueError: Expecting property name: line 1 column 2 (char 1)
- mongodb cursor id not valid error
- Don’t understand why UnboundLocalError occurs (closure) [duplicate]
- Why is the order in dictionaries and sets arbitrary?
- How to add pandas data to an existing csv file?
- Get IP address of visitors using Flask for Python
- Sum a list of numbers in Python
- Finding all possible permutations of a given string in python
- googletrans stopped working with error ‘NoneType’ object has no attribute ‘group’
- How do I increase the cell width of the Jupyter/ipython notebook in my browser?
- Python – Extracting and Saving Video Frames
- How to assign a name to the size() column?
- Python & MySql: Unicode and Encoding
- Multiple linear regression in Python
- Full examples of using pySerial package [closed]
- Write to UTF-8 file in Python
- Python: call a function from string name [duplicate]
- Variable defined with with-statement available outside of with-block?
- Django: How to manage development and production settings?
- How can I use ‘Not Like’ operator in MongoDB
- Does Python evaluate if’s conditions lazily? [duplicate]
- Trying to delay a specific function for spawning enemy after a certain amount of time
- What is the difference between join and merge in Pandas?
- Python TypeError: non-empty format string passed to object.__format__
- Spark DataFrame TimestampType – how to get Year, Month, Day values from field?
- cx_Freeze crashing Python 3.7.0
- Is there a ‘multimap’ implementation in Python?
- Rounding to two decimal places in Python 2.7?
- Fastest way to swap elements in Python list
- Pyodbc error Data source name not found and no default driver specified paradox
- python-win32com excel com model started generating errors
- Can a dictionary be passed to django models on create?
- Inheritance best practice : *args, **kwargs or explicitly specifying parameters [closed]
- Python modbus library [closed]