[Answer]-Django/Python unorderable types: complex() < complex() Django tutorial youtube-croach

1👍

Yes, it has changed a bit. Now you have to specify a lambda for your sorting because key has to be something that is callable.
Using lambda makes it callable on every item of the iterable object which you are using – ensuring that key can be used across any kind of object instances your own classes.

Try the following:

ranked_stories = sorted(latest_stories, key=lambda story: store.score(), reverse=True)

You may make it as complex as you want using the score object and that’s the beauty of lambda

Leave a comment