Optimized code for sort, added sort for ID and a general bubble sort for date & time