I have the following block of python code
b = c.get_bucket(bucket)
lst = []
for prfx in prefix_list:
for f in b.list(prefix=prfx):
lst.append(f)
sorted(lst, key=lambda kk: kk.last_modified, reverse=True)
Basically, I create a list of AWS S3 keys (lst) from another list of prefixes (prefix_list) and then try to sort this list by the last modification date of the keys. I am probably making some basic Python error here, ‘cuz lst does not get sorted. What am I doing wrong?
Make sure to grab the return value. sorted() returns a new list, it doesn’t modify the existing one in place.