[Tutor] Function calls

Alan Gauld alan.gauld at freenet.co.uk
Sun Nov 14 19:40:53 CET 2004

> >>> min3(1,3,4,5,6,[1,3,4,0])
> 1
> >>> min3(1,2,3,4,5,(1,0))
> 1
> Why isnt it showing '0' as the minimun value. this
> function should report min value irrespective of a
> list or a tuple passed to an argument as a call.

In both cases there are only 6 elements to be sorted, 
sort does not unpack nested lists/tuples.

Python's sorting algorithm for lists considers a single item 
element to be less than a multi item element. This is an 
arbitrary choice (although it makes some sense to me!) and 
the author culd have gone the other way but didn't.


Alan G

More information about the Tutor mailing list