[Tutor] sorted question

Marc Tompkins marc.tompkins at gmail.com
Wed Jan 26 01:37:13 CET 2011


On Tue, Jan 25, 2011 at 11:46 AM, It't me <linux4n6 at gmail.com> wrote:
> Hi all,
>
> I'm learning Python with Google's Python class
>
> Ik have a question about the following code:
> =================================
> def sort(var):
>  return var[-1]  #returns the last character of var
>
> def sort_last():
>   tup = [(1, 3), (3, 2), (2, 1)]
>   print(sorted(tup, key=sort))
>
> sort_last()
> ==================================
>
> I uderstand everything except (var) value.
> I understand that key=sort calls the sort function.
> But where comes the var value from?
> Does sort automatic pass the value from tup to (var)
>
> because (var) is nowhere defined.
>
> Thanks,
>
> Martin

Could you post the URL to that class?  'Cause I don't see it either,
from what you've posted.  If that's all there is, something is
profoundly wrong.


-- 
www.fsrtechnologies.com


More information about the Tutor mailing list