Sort array by dates.