Cody Bable

Generation

generate functionFri, 30 Jun 2023

return list dictionary of the two biggest numbers in a list of dictionaries

# input: [{'key':1},{'key':2},{'key':3}] # output: [{'key':3},{'key':2}] def largestTwo(dictionaries): return sorted(dictionaries, key=lambda item: item['key'], reverse=True)[:2]

Questions about programming?Chat with your personal AI assistant