Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python ordering items in a list

# Ordering
[1,2,5,3].sort()         # None --> Mutates list to [1, 2, 3, 5]
[1,2,5,3].sort(reverse=True) # None --> Mutates list to [5, 3, 2, 1]
[1,2,5,3].reverse()      # None --> Mutates list to [3, 5, 2, 1]
sorted([1,2,5,3])        # [1, 2, 3, 5] --> new list created
list(reversed([1,2,5,3]))# [3, 5, 2, 1] --> reversed() returns an iterator
Comment

PREVIOUS NEXT
Code Example
Python :: convert from python to curl 
Python :: pycharm display info of function 
Python :: download python for windows 7 32 bits 
Python :: multiplication table for number python codewars 
Python :: df convert dtypes 
Python :: python heroku 
Python :: convert days hours minutes into seconds python 
Python :: run a python file from another python file 
Python :: how to launch a application using python 
Python :: python move 
Python :: length of a list python 
Python :: select specific columns in sqlalchemy 
Python :: python __dict__ 
Python :: format python decimal 
Python :: sort list of list of dictionaries python 
Python :: range parameters python 
Python :: pygame buttons 
Python :: if else usage python 
Python :: math in python 
Python :: python range of array 
Python :: games made with python 
Python :: list python 
Python :: python coin flip 
Python :: what is repr function in python 
Python :: rename data columns pandas 
Python :: how to get a user input in python 
Python :: new line 
Python :: ceil in python3 
Python :: Finding the maximum element from a matrix with Python numpy.argmax() 
Python :: check if a number is integer or decimal in python 
ADD CONTENT
Topic
Content
Source link
Name
3+6 =