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.
Static arrays in D are value types. Try:
thing[].sort();
This will pass a slice of the array to sort, holding a reference
to the static array's data.