finally figured out sortingTime function. Thank god haha, but this is debugged as well. time to start adding comments.