About 50 results
Open links in new tab
  1. python - Why does "return list.sort ()" return None, not the list ...

    The sort function is an operation over the data represented by an object and returns a new object with the same contents in a sorted order. Given a list of integers named l the list itself will be reordered if …

  2. python - What is the difference between sorted (list) vs list.sort ...

    The .sort () function stores the value of new list directly in the list variable; so answer for your third question would be NO. Also if you do this using sorted (list), then you can get it use because it is not …

  3. python - Sort a list of lists with a custom compare function - Stack ...

    I want to sort this list by applying a custom compare function to each element. This function calculates the fitness of the list by which the elements shall be sorted.

  4. How does the key argument in python's sorted function work?

    The function you pass in to key is given each of the items that are being sorted, and returns a "key" that Python can sort by. So, if you want to sort a list of strings by the reverse of the string, you could do this:

  5. 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?

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

    Mar 20, 2012 · You don't need a custom function for what you want to achieve, you first need to understand the methods you are using! sort() ing a list in python does it in place, that is, the return …

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

    Dec 29, 2009 · Sequences can contain any objects, not even comparable, but if we can define a function which produces something we can compare for each of the items, we can pass this function in key …

  8. python - Syntax behind sorted (key=lambda: ...) - Stack Overflow

    To define lambda, you specify the object property you want to sort and python's built-in sorted function will automatically take care of it. If you want to sort by multiple properties then assign key = lambda x: …

  9. Sort python list by function - Stack Overflow

    Aug 21, 2011 · 2 A lambda function is useful if your sorting function takes a support argument, otherwise function name is enough. For example, if you want to sort list of string representation of datetime by …

  10. python - What is the complexity of the sorted () function? - Stack …

    Jan 21, 2013 · I have a list of lists and I am sorting them using the following data=sorted(data, key=itemgetter(0)) Was wondering what is the runtime complexity of this python function?