DeveloperBreeze

Sort a List

The following Python code demonstrates how to sort a list of fruits alphabetically using the sort() method:

# Define a list of fruits
fruits = ['apple', 'banana', 'cherry', 'date', 'fig']

# Sort the list alphabetically
fruits.sort()
print('Sorted Fruits:', fruits)

Related Posts

More content you might like

Code
java

Java: How to Sort a List

No preview available for this content.

Aug 12, 2024
Read More
Code
javascript

Sorting an Array in JavaScript

No preview available for this content.

Jan 26, 2024
Read More
Code
javascript

Sorting an Array

No preview available for this content.

Jan 26, 2024
Read More
Code
python

Sort List of Objects by Attribute in Python

No preview available for this content.

Jan 26, 2024
Read More

Discussion 0

Please sign in to join the discussion.

No comments yet. Be the first to share your thoughts!