About 50 results
Open links in new tab
  1. python - What is the difference between sorted (list) vs list.sort ...

    The sort () method just sorts the elements of a given list in a specific order - Ascending or Descending without returning any value. The syntax of sort () method is:

  2. python - Why does "return list.sort ()" return None, not the list ...

    The sort method operates on the contents of the object named -- think of it as an action that the object is taking to re-order itself. The sort function is an operation over the data represented by an object and …

  3. python - How to sort a list of strings? - Stack Overflow

    Aug 30, 2008 · As sort() sorts the list in place (ie, changes the list directly), it doesn't return the sorted list, and actually doesn't return anything, so your print statement prints None. If you saved your list to …

  4. Python sort () method on list vs builtin sorted () function

    The above snippet showed something interesting that, python's sort function behaves very well for already sorted data. As pointed out by Anurag, in the first case, the sort method is working on …

  5. Why does '.sort()' cause the list to be 'None' in Python?

    Mar 20, 2012 · I am attempting to sort a Python list of ints and then use the .pop() function to return the highest one. I have tried a writing the method in different ways: def LongestPath(T): paths = [

  6. What algorithm does python's sorted() use? - Stack Overflow

    Jun 8, 2012 · Timsort was Python's standard sorting algorithm from version 2.3 to version 3.10. It is now also used to sort arrays in Java SE 7, and on the Android platform. Since 3.11, Python uses …

  7. sorting - Sort a list of Class Instances Python - Stack Overflow

    Jul 27, 2012 · In addition to the solution you accepted, you could also implement the special __lt__() ("less than") method on the class. The sort() method (and the sorted() function) will then be able to …

  8. python - How do I sort a dictionary by key? - Stack Overflow

    Jan 26, 2017 · A simple way I found to sort a dictionary is to create a new one, based on the sorted key:value items of the one you're trying to sort. If you want to sort dict = {}, retrieve all its items using …

  9. What algorithm does Python's built-in sort () method use?

    Oct 4, 2009 · What algorithm is the built in sort() method in Python using? Is it possible to have a look at the code for that method?

  10. What arguments does Python sort() function have? - Stack Overflow

    Dec 29, 2009 · Besides key=, the sort method of lists in Python 2.x could alternatively take a cmp= argument (not a good idea, it's been removed in Python 3); with either or none of these two, you can …