Fix KeyError when sorting the list by safety remove all items before populate