Closed boyney123 closed 2 months ago
Given the immutability nature that we're trying to achieve in Wing, maybe it'd make more sense if the array sort method returned a new sorted array:
let unsorted = [1, 10, 5];
let sorted = unsorted.sort();
Allow passing a compare function is a must, too 👍🏻. Not sure about the API for Array
and MutArray
, though... unsorted.sort()
and unsorted.sortMut()
?
Perhaps something like array.sort()
for sorting in-place and array.sorted()
for returning a shallow copy that has been sorted? (sorting in-place would only be allowed on MutArray
)
Closing as duplicate of https://github.com/winglang/wing/issues/4998
Use Case
I have some array, it would be nice to be able to sort it.
Proposed Solution
Implementation Notes
No response
Component
No response
Community Notes