Closed skilesare closed 4 months ago
What size of vector would you like to sort? Vector is usually meant for sizes that so large that either a) heap allocations (garbage creation) of Buffer become a problem or b) instruction spikes when growing the Buffer become a problem. Otherwise people can use Buffer. So Vector is usually meant for cases where size is "large" relative to the canister's instruction or memory limits. But when you are close to those limits then the question is if you really want to sort a vector of that size? That might require a sort algorithm that can be interrupted half-way through and that can be continued in the next execution.
If you are only using Vector (over Buffer) out of habit and the size is small then we can of course provide a convenience function for sorting. Internally the function would write the elements into an Array, apply the base library's sort function, and then write the elements back into the Vector. Is that ok for you needs?
I'm currently having to dump to array to to sort and I don't think that is likely efficient. Some kind of sort and/or sortInPlace would be great for this library.