Why can't static arrays be sorted?

Adrian Matoga via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Oct 4 13:08:01 PDT 2016


On Tuesday, 4 October 2016 at 20:05:15 UTC, TheGag96 wrote:
> I was writing some code today and ran into this oddity that I'd 
> never come across before:
>
>     import std.algorithm : sort;
>     int[10] arr = [0, 3, 4, 6, 2, 1, 1, 4, 6, 9];
>     thing.sort();
>
> This doesn't compile. Obviously the .sort property works, but 
> what about static arrays makes them unable to be sorted by 
> std.algorithm.sort? Thanks.


Try:
arr[].sort();


More information about the Digitalmars-d-learn mailing list