The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,860 other subscribers

python – Why does “return list.sort()” return None, not the list? – Stack Overflow

Posted by jpluimers on 2020/01/02

list.sort sorts the list in place, i.e. it doesn’t return a new list. Just write

newList.sort()
return newList

The above answer is goden as performing return list.sort() bytes me often, because Python is usually an environment using the functional approach.

Answer from [WayBack] python – Why does “return list.sort()” return None, not the list? – Stack Overflow

Background information:

–jeroen

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.