and was quite surprised to see a non-sorted result. In a minute, I realized that our List.sorted() API contract takes the value of inPlace argument as a suggestion and not a requirement. If the List (in this case an Array) is immutable it creates a new array, sorts and returns it. I think it's wrong and it should throw.
Proposed is the corresponding API doc and implementation change
While working on something, I wrote a simple test similar to this:
and was quite surprised to see a non-sorted result. In a minute, I realized that our List.sorted() API contract takes the value of
inPlace
argument as a suggestion and not a requirement. If the List (in this case an Array) is immutable it creates a new array, sorts and returns it. I think it's wrong and it should throw.Proposed is the corresponding API doc and implementation change