Sorting Arrays directly

Hi, I was wondering, why there is sort function within the Array module. It seems to me, that the List module makes use of this feature by translating lists to arrays and back after sorting. Wouldn’t it be nice to expose the same functionality also to arrays directly? I know (Array.toList >> List.sort >> Array.fromList) would be an option, but I do not like the translation steps. Or, is it not such a huge performance issue?

I know ( Array.toList >> List.sort >> Array.fromList ) would be an option, but I do not like the translation steps. Or, is it not such a huge performance issue?

The performance of this would be “noticeable”, though likely only in benchmarks or extremely large lists.

I guess it would be a possible addition to the core Array API, but I am not privy to the details, and I don’t know if there a good reasons not to, or whether it’s intentional or something that was forgotten.

1 Like

I thought so either (in performance), doing statistics would be a bit faster with arrays, if there would be more “native” functions like sort or sum or product … (at least sort and sum)

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.