Updated sorting function to sort by year and month
Updated test