Sort history by time using bubblesort