Loop over a sequence in sorted order

# Loop over a sequence in sorted order, use the sorted() function which returns a
# new sorted list while leaving the source unaltered.
basket = ['apple', 'orange', 'apple', 'pear', 'orange', 'banana']
for f in sorted(set(basket)):
print f
Related examples in the same category