G’d evening Monties and Pythoners
I’m starting to learn Python and I wish to understand this different behaviour (I’m using interactive console 3.7 over Win):
Let fruits = ['orange','apple','apple','banana']
thus set(fruits)
===> {‘orange’, ‘apple’, ‘banana’}
and sorted(fruits)
===> [‘apple’, ‘apple’, ‘banana’, ‘orange’]
NOW
sorted(set(fruits)) ===> ['apple', 'banana', 'orange']
BUT
set(sorted(fruits)) ===> {'apple', 'orange', 'banana'}
Given that sorted(fruits) is [‘apple’, ‘apple’, ‘banana’, ‘orange’],
how come set(['apple', 'apple', 'banana', 'orange'])
would place ‘banana’ last? what’s it got against bananas?