I've been a professional C, Perl, PHP and Python developer.
I'm an ex-sysadmin from the late 20th century.
These days I do more Javascript and CSS and whatnot, and promote UX and accessibility.
Vicki, once a manager of aircraft maintenance, is now charming Python & Ruby. She has coded OpenGates.dev, #VetsWhoCode bot, Code Questions bot, & LGBTQ of the Day Bot. They love relatable writing.
Location
Richmond, Virginia
Education
Self Taught Python/Ruby, BBA in Small Business Mgmt, AS in Production Mgmt
I've been a professional C, Perl, PHP and Python developer.
I'm an ex-sysadmin from the late 20th century.
These days I do more Javascript and CSS and whatnot, and promote UX and accessibility.
yes, array.sort and sorted take a named parameter in Python 3 (I had to learn this a couple of days ago!) which is run as a callback, once per key, immediately before sorting the elements. So that example calls x: x["age"] on every element first.
It's the equivalent of this:
For your example of a "function inside another function", do you mean something like this?
I think this is what I was referring to, but I’m not super sure. All the examples I saw were using functions like map(), filter(), and sort()
I’ve never seen
keyused before. Help me out, what isxdoing in this?If I’m reading this correctly, it’s just sorting these key-value pairs by age, right?
yes,
array.sortandsortedtake a named parameter in Python 3 (I had to learn this a couple of days ago!) which is run as a callback, once per key, immediately before sorting the elements. So that example callsx: x["age"]on every element first.It's the equivalent of this:
and this: