Python is an open-source programming language ideal for learning how to program, due to its easy-to-read programming syntax. A common Python programming task is sorting a list of items in alphabetical order. For example, you may need to sort a list of items that your company needs to purchase. To sort a list in alphabetical order, use Python’s built-in “Sorted” function. groceryList = (‘apple’, ‘candy’, ‘berries’, ’nuts’) sorted (groceryList) [‘apple’, ‘berries’, ‘candy’, ’nuts’] In the example above, Python sorts the strings in the variable, ‘groceryList,’ and returns a list, signified by brackets, containing the strings sorted in alphabetical order. Writer Bio
