cannot sort an array of char

Ali Çehreli via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Nov 5 10:01:10 PST 2014


On 11/05/2014 05:44 AM, "Marc Schütz" <schuetzm at gmx.net>" wrote:
> On Wednesday, 5 November 2014 at 13:34:05 UTC, Marc Schütz wrote:
>> On Wednesday, 5 November 2014 at 12:54:03 UTC, Ivan Kazmenko wrote:
>>> Hi!
>>>
>>> This gives an error (cannot deduce template function from argument
>>> types):
>>>
>>> -----
>>> import std.algorithm;
>>> void main () {
>>>     char [] c;
>>>     sort (c);
>>> }
>>> -----
>>>
>>> Why is "char []" so special that it can't be sorted?
>>>
>>> For example, if I know the array contains only ASCII characters,
>>> sorting it sounds no different to sorting an "int []".
>>
>> Hmm... this doesn't work either:
>>
>>     import std.algorithm;
>>     import std.utf;
>>     void main () {
>>         char [] c;
>>         sort (c.byCodeUnit);
>>     }
>>
>> But IMO it should.
>
> https://issues.dlang.org/show_bug.cgi?id=13689

It can't be a RandomAccessRange because it cannot satisfy random access 
at O(1) time.

Ali



More information about the Digitalmars-d-learn mailing list