Use
a = sorted(a, key=lambda x: x.modified, reverse=True) # ^^^^
On Python 2.x, the sorted
function takes its arguments in this order:
sorted(iterable, cmp=None, key=None, reverse=False)
so without the key=
, the function you pass in will be considered a cmp
function which takes 2 arguments.
Related Posts:
- Python list sort in descending order
- How to sort 2d array by row in python?
- How to use filter, map, and reduce in Python 3
- how to sort pandas dataframe from one column
- How do I sort a dictionary by value?
- How do I sort a dictionary by value?
- How do I sort a dictionary by value?
- How to use Collections.sort() in Java?
- Python Math – TypeError: ‘NoneType’ object is not subscriptable
- Quicksort with Python
- How can I sort a dictionary by key?
- How does functools partial do what it does?
- Finding median of list in Python
- C library function to perform sort
- Syntax behind sorted(key=lambda: …)
- Using a comparator function to sort
- How to sort a list of objects based on an attribute of the objects?
- How to sort a list/tuple of lists/tuples by the element at a given index?
- Python data structure sort list alphabetically
- How to use Comparator in Java to sort
- Efficiently sorting a numpy array in descending order?
- Why is the minimalist, example Haskell quicksort not a “true” quicksort?
- Why does heap sort have a space complexity of O(1)?
- Find the unique values in a column and then sort them
- pandas groupby sort within groups
- How can I sort a Perl hash on values and order the keys correspondingly (in two arrays maybe)?
- Sorting arrays in NumPy by column
- Sorting list based on values from another list
- How do operator.itemgetter() and sort() work?
- Why quicksort is more popular than radix-sort?
- Elasticsearch ordering by field value which is not in the filter
- How do I copy a file in Python?
- Use Gif Logo For Loading Screen In Kivy
- How can I make a time delay in Python? [duplicate]
- beyond top level package error in relative import
- How do you append to a file?
- sklearn error ValueError: Input contains NaN, infinity or a value too large for dtype(‘float64’)
- Jupyter Notebook not saving: ‘_xsrf’ argument missing from post
- What does it mean to have an index to scalar variable error? python
- Could not install packages due to an EnvironmentError:
- What does “e” in “1e-5” in Python language mean and what is the name of this notation?
- How to avoid “RuntimeError: dictionary changed size during iteration” error?
- ‘Conda’ is not recognized as internal or external command
- pip/python: normal site-packages is not writeable
- Why do people write #!/usr/bin/env python on the first line of a Python script?
- How to raise a numpy array to a power? (corresponding to repeated matrix multiplications, not elementwise)
- How to know the version of pip itself
- Microsoft Visual C++ 14.0 is required (Unable to find vcvarsall.bat)
- How to import other Python files?
- Python TypeError: not enough arguments for format string
- Python virtualenv questions
- How to activate virtualenv in Linux?
- Pinging servers in Python
- TypeError: object of type ‘int’ has no len() error assistance needed
- TypeError: unsupported operand type(s) for /: ‘str’ and ‘str’
- append multiple values for one key in a dictionary [duplicate]
- Spark RDD to DataFrame python
- Sorting Characters Of A C++ String
- index 1 is out of bounds for axis 0 with size 1
- How can I time a code segment for testing performance with Pythons timeit?
- Python: tuple indices must be integers, not str when selecting from mysql table
- AttributeError: ‘list’ object has no attribute ‘replace’
- Countdown timer in Pygame
- Python [Errno 98] Address already in use
- Difference between writerow() and writerows() methods of Python csv module
- What are the causes of overflow encountered in double_scalars besides division by zero?
- Creating a dictionary from a csv file?
- How can I check for NaN values?
- Bad operand type for unary +: ‘str’
- How do I get the parent directory in Python?
- How to fix: “UnicodeDecodeError: ‘ascii’ codec can’t decode byte”
- How to read a text file into a list or an array with Python
- Map to List error: Series object not callable
- How to convert ‘binary string’ to normal string in Python3?
- What is the meaning of curly braces?
- Copy a list of list by value and not reference
- How do I print bold text in Python?
- python3 TypeError: ‘function’ object is not iterable
- pip connection failure: cannot fetch index base URL http://pypi.python.org/simple/
- Moving average or running mean
- Python 3.6 No module named pip
- Difference between import tkinter as tk and from tkinter import
- Split function add: \xef\xbb\xbf…\n to my list
- ImportError in importing from sklearn: cannot import name check_build
- Root mean square of a function in python
- Installing opencv on Windows 10 with python 3.6 and anaconda 3.6
- H14 error in heroku – “no web processes running”
- What is an easy way to implement fprintf in python?
- What is the recommended way to use Vim folding for Python code
- Plotting a python dict in order of key values
- How to normalize a NumPy array to within a certain range?
- How to check if a user is logged in (how to properly use user.is_authenticated)?
- Can I remove script tags with BeautifulSoup?
- Python ‘while’ with two conditions: “and” or “or”
- How to pass a list by reference?
- Python Quicksort Runtime Error: Maximum Recursion Depth Exceeded in cmp
- “for loop” with two variables?
- Python webbrowser.open() to open Chrome browser
- Flatten nested dictionaries, compressing keys
- Sending posts from Python to WordPress