Sort data based on time and save only 50 records