sorted vs sort python

Solutions on MaxInterview for sorted vs sort python by the best coders in the world

showing results for - "sorted vs sort python"
Elif
28 Oct 2016
1# The sort() function will modify the list it is called on. 
2# The sorted() function will create a new list 
3# containing a sorted version of the list it is given.
4
5list = [4,8,2,1]
6list.sort()
7#--> list = [1,2,4,8] now
8
9list = [4,8,2,1]
10new_list = list.sorted()
11#--> list = [4,8,2,1], but new_list = [1,2,4,8]
12
Ben
28 Feb 2019
1The primary difference between the list sort() function and
2the sorted() function is that the sort() function will modify
3the list it is called on. The sorted() function will create a 
4new list containing a sorted version of the list it is given.
5... The sort() function modifies the list in-place and has no return value.
queries leading to this page
python difference between sort and sortedpython sort 28 29 vs sorted 28 29sorting in python 5b 3a 2c 1 5dsort 28 29 vs sortedpython copy sorted listpython sort and sortedwhat is python sort ordersort vs sorted pythonordy by pythonstring sort vs string sorted pythonsort vs sorted method in pythonsorted key by highest numberpythonhow efficient is sorted pythonpython sorted list typesort list by the difference between valuessorted function in pythonpython sorted 28 29 vs sort 28 29python return sorted listpython sort 28 29 vs sortedsorted python descendingcompare and return ordered string in pythondoes sorted sort set pythonsorted 28 29 vs sort 28 29 pythonwhats the difference between sort and sortedsorted vs sort in pythonwhat is the difference between sorted and sort in pythonsorted in pythondifference sort sorted pythonsorted vs sort pythonsort 28 29 vs sorted 28 29 pythonpython sort other than sort 28 29python sort lambdalist sort vs sortedsorted a python list by value which has valuespython sirt vs sorteddiff between sort and sorted in pythonpython sort vs sorted 3fdifference between sort 28 29 and sorted 28 29 in pythonset is sorting my vaules by default pythonuser defined function to sort number in pythonhelp sorted pythonpython copy sorted directory python sorted vs sortsorted function vs sort function in pythonpython sort vs sorteddifferences between sort 28 29 and sorted 28 29 in pythonsorted means in python sort 28 29 vs sorted 28 29write two disadvantages of sort 28 29 function over a list pythonsorted python with different typessorted python vs sortstring slicing after sort python now workingsort vs sorted in pysort and sorted in pythonpython sort sorted differencesort list and store in pythonsorting function from the end of list to the beginningis sorted pythonpython sort vs sorted listsort 28a 2cb 29 pythonsorted 28 29 vs sort pythonpython list sort vs sortedsorted pythonlist sort vs sortedsorting values in a list via method pythonsort data in standard output pytpython cut sorted list by valuesorted 28 29 pythondifference between sorted and sort in pythonwhat is the difference of sort and sorted functions in python 3how to sorting in python workshow to import sort in pythonhow do i sort 1 10 in pythonpython sortedpython sorted 28 29 vs sorted 28 29sort and sorted in pythopython sort vs sorted list reverse orderpython difference sort and sortedlist sort 28 29 vs sorted pythonpython orderedpython sort orderpython sort lambda integerpython sort and sorted differencesort float by spliyt jojinpython2 python3 sorted none problemsorted vs list sort sort or sorted pythonsorted or sort pythonsort and sorted pythondifference between sort and sorted 28 29python sort sorteddifference sort and sorted pythonhow to limit the sort in pythonhow to use sorted in pythonsorted 28 29 vs sort 28 29sort sorted pythonsorted 28 29 difference with sort 28 29 in pythoncorrect order pythonpython sort list and returnsort and order pythonrules for sorting pythondifference between sort and sorted in pythosort 28 29 vs sorted 28 29sort vs sorted python 3 difference between sort and sorted 3fpython sort vs sortedsorted vs sort python outputhow to sort string pythondifference between sort 28 29 and sorted 28 29sorted and sort in pythondifference between sort and sorted in pythonwhat is the difference between sort and sorted in pythonpython sorting vs sort sort vs sortedpython sorted vs list sortpython sortsort vs sorted in pythonpython sorted vs sort performancepython how works sortsort vs sorted in pythonuse sort in pythonnot list but sortedwhat is difference between sort and sorted in pythonsorted vs sort pythonsorted more than one variableexamples pythondifference between sorted and sort pythonsort vs sortedpython sort vs sortedpython a sort and sort 28a 29list sort vs sorted pythonsorted vs sort python