Converting to sets then back to lists