I created a dictionary:
listing = {'2': 'Mary Lejam', '3': 'Zachery Aka', '1': 'John Joer', '4': 'Joe Private', '10': 'Carla Chris'}
I'm writing a simple program that sorts the names according to the keys (which are the id) and sort according to last name I figure out the id one with the keys of the dictionary. But now i'm trying to find a way to sort the last name.
- if i do listing.values(), it sorts with the first letter of the first name
- if i use the itemgetter, i can only put an index that it will sort with.
I tried importing re, such as itemgetter(re.match(regex))
, gives me error
I was wondering if it is possible to use itemgetter and write some regex inside it to ignore everything before the last name. It would ignore everything before the space basically.
LastName = sorted(listing.values(), key=itemgetter(Some Regex))