Ok, ok... I see the direction, but I still miss something:
From the point of view of "Programming in D", chapter 33.3,
"Immutability of the slice vs the elements":
I don't want to have an immutable slice but immutable elements.
And your answers imply that sorting not only modify the slice
itself but also mutate the elements. This is a little bit
strange, in my opinion, as sorting modifies only relationships
between the sorted elements not the elements itself. At least in
my head, at least for the moment :)
A test says the same thing:
void main()
{
immutable int[] immSlice = [2, 1];
sort(immSlice);
}
and
void main()
{
immutable(int)[] immSlice = [2, 1];
sort(immSlice);
}
both give errors:
Error: template std.algorithm.sorting.sort cannot deduce function
from argument types !()(immutable(int[]))
and
Error: template std.algorithm.sorting.sort cannot deduce function
from argument types !()(immutable(int)[])
respectively.
So the question remains, how to sort? Do you think removing the
immutable property from an id is the semantically right way? Or
do you have a hint, maybe something like, a dup copy with
removing immutability and returning a new, sorted copy? If you
think the latter is the way to choose, how is the syntax there? ;)