Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Lambda Functions
#15
To think of something that i use lambda quite often in sorting comes to mind.
There is an alternative itemgetter,but then have to import it.
>>> lst = [('Tom', 'C', 10), ('Kent', 'A', 12), ('Jenny', 'B', 15)]
>>> sorted(lst, key=lambda tup: tup[1])
[('Kent', 'A', 12), ('Jenny', 'B', 15), ('Tom', 'C', 10)]
Reply


Messages In This Thread
Lambda Functions - by ATXpython - Sep-28-2016, 10:29 PM
RE: Lambda Functions - by micseydel - Sep-28-2016, 10:35 PM
RE: Lambda Functions - by ATXpython - Sep-29-2016, 01:44 AM
RE: Lambda Functions - by metulburr - Sep-29-2016, 03:10 AM
RE: Lambda Functions - by nilamo - Sep-29-2016, 03:29 PM
RE: Lambda Functions - by j.crater - Sep-29-2016, 05:58 PM
RE: Lambda Functions - by micseydel - Sep-29-2016, 06:00 PM
RE: Lambda Functions - by j.crater - Sep-29-2016, 06:11 PM
RE: Lambda Functions - by snippsat - Sep-29-2016, 06:42 PM
RE: Lambda Functions - by nilamo - Sep-29-2016, 06:08 PM
RE: Lambda Functions - by nilamo - Sep-29-2016, 06:26 PM
RE: Lambda Functions - by Larz60+ - Sep-29-2016, 06:44 PM
RE: Lambda Functions - by metulburr - Sep-29-2016, 07:03 PM
RE: Lambda Functions - by nilamo - Sep-29-2016, 07:05 PM
RE: Lambda Functions - by snippsat - Sep-29-2016, 08:05 PM
RE: Lambda Functions - by ATXpython - Sep-29-2016, 10:09 PM
RE: Lambda Functions - by Larz60+ - Sep-30-2016, 01:42 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Multiple lambda functions in zipped list not executing psolar 0 1,628 Feb-13-2020, 12:53 PM
Last Post: psolar

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020