Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

3
  • 18
    The concept of the List implies that there is some order and that list.get(n) operation will be deterministic, meaning it will always return the same element at position n as long as the list is not modified. I don't agree that the "concept of a List" requires that to be the insertion order. Yes, the List interface does feature list.add(index, element) method which doesn't make sense for a sorted collection, but it's optional according to the docs. Commented Jun 13, 2020 at 8:40
  • No one said it should be "automatically sorted". Simply that once it's sorted, there should be a contract guaranteeing that the order cannot be chnaged. It could mean that the list is now immutable (no more insertions or deletions), but that's irrelevant. Sorted means "you can't change the order if you were not given the tools or permissions to do so" Commented May 31, 2024 at 13:44
  • Nice explanation! Thanks. Commented Mar 13 at 20:26