Python Dictionaries Doubt

at 2:33:35,

it is being said that SORT on a LIST is done based on the key, but aren’t we sorting it by value?

Or what has been implied is that we have interchanged value and key with each other of dictionary items while appending it to another empty list?

Thanks.

The key or the criteria for the sorting of the values in a list can be a single value or a tuple.

Let us take an example where the criteria involve three values.

What will be the result of sorting the following? : [(1,2, 1), (1, 2, 0), (1,2, 3)]

> >>> sorted([(1,2, 1), (1, 2, 0), (1,2, 3)])
> [(1, 2, 0), (1, 2, 1), (1, 2, 3)]

I hope it is clear to you.

1 Like

Ohh…kay, and the words in the tuple/list will be sorted as per their ASSCI codes/order of alphabets when they are compared with each other respectively.

Thank you sir! :slightly_smiling_face: :+1:

i did not understand.

what is

and i did not understand that why “Cloudxlab” is added in xyz_str ?

i did not understand whole program.

please explain.

greetings

Nirav Raj

Are you talking about the the program being mentioned at 2:33:35 in the video above or something else? Kindly clarify.
Thanks.

kindly,

lesson 65

Parameters and Arguments

i did not understand the whole program.

please explain

greetings :wink:

Nirav raj