Fixed sorting of history entries