Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Sorted iteration

basket = ['pear', 'banana', 'orange', 'pear', 'apple']

# use sorted to return a new sorted list before iterating
for fruit in sorted(basket):
  print(fruit)

# =>
# apple
# banana
# orange
# pear
# pear
Source by monolith.propulsion-home.ch #
 
PREVIOUS NEXT
Tagged: #Sorted #iteration
ADD COMMENT
Topic
Name
3+7 =