DEV Community


Discussion on: Flatten and Sort an Array of Arrays JavaScript

darkwiiplayer profile image

Checking an unsorted array for duplication requires keeping track of elements you've seen before though, whereas if they're next to each other you can just walk through the array and drop elements that are the same as the previous one. For longer arrays this can be a considerable memory improvement.