# Get latest Item by Date for a Recommender System

I am building a Recommender System where I am giving the User 3 Recommendations depending upon for the Webpage he is on. Let's say My model gives me 3 Recommendations from 2020, 2019, 2015. I would first recommend the User the 2020 article and so on. Currently what I am doing is just filtering the JSON Recommendations from my Dataframe as the Latest articles. Is there any Scalable and efficient way to do this.

[('https://www.webpage.tv/,
'2019-06-04T00:00:00'),
('https://www.webpage.tv/',
'2019-08-30T00:00:00'),
('https://www.webpage.tv/',
'2020-03-02T00:00:00')]

output_df['latest'] = output_df['recommendations'].apply(lambda x : sorted([(value,key) for key,value in x.items()], key=lambda x:x[1]))