Computer Science, asked by akshat0603, 4 months ago

Q.2
Write a program in Python where a list of 5 integers is passed to a function
SORT( ilst ) and this function will arrange all the elements of a list in ascending
order using SELECTION SORT METHOD​

Answers

Answered by VEDESWARITS
1

Answer:

The sort() method sorts the elements of a given list in a specific ascending or descending order. The syntax of the sort() method is: list. sort(key=..., reverse=...)Use zip() to sort a list based on another list. Call zip(*iterables) on the list to sort by and the list to sort, in that order. Call sorted(iterable) on the constructed zip object to create a sorted list of tuples representing pairings between the two lists.How to sort the objects in a list in Python?

my_list = [1, 5, 2, 6, 0] my_list. sort() print(my_list) my_list. ...

my_list = [1, 5, 2, 6, 0] print(sorted(my_list)) print(sorted(my_list, reverse=True)) Output. ...

def get_my_key(obj): return obj['size'] my_list = [{'name': "foo", 'size': 5}, {'name': "bar", 'size': 3}, {'name': "baz", 'size': 7}] my_list.

Similar questions