Fix sorting of media items in history method