converting a set into a sorted list

Brian Beck exogen at gmail.com
Sat May 14 23:06:32 EDT 2005


Robert Kern wrote:
> MackS wrote:
> 
>> Dear all,
>>
>> I've got several large sets in my program. After performing several
>> operations on these I wish to present one set to the user [as a list]
>> sorted according to a certain criterion. Is there any direct way to do
>> so? Or must I
>>
>> list = []
>>
>> for item in set1:
>>    list.append(item)
>>
>> list.sort(....)

So, for this example, just do:

sorted(set1)


-- 
Brian Beck
Adventurer of the First Order



More information about the Python-list mailing list