Sort using Uniform call syntax
Jonathan M Davis via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Mar 14 06:56:07 PDT 2016
On Monday, March 14, 2016 04:14:26 Ali Çehreli via Digitalmars-d-learn wrote:
> On 03/14/2016 04:01 AM, Jerry wrote:
> > I have a small problem with using UCS when sorting arrays. This pops a
> > warning telling me to use the algorithm sort instead of the property
> > sort. Which I understand why it works that way. However that means I can
> > not have syntactic sugar. So is there any way around this or do I just
> > have to live with it?
>
> Two options:
>
> a) Use parentheses after sort:
>
> arr.sort()
>
> b) Import sort() under a different name:
>
> import std.algorithm: algsort = sort;
>
> arr.algsort
Yep. The sort property on arrays will likely go away eventually, but until
it does, those are your options. But at least now it warns you. Previously,
it just silently used the sort property, which does the wrong thing for
arrays of char or wchar.
- Jonathan M Davis
More information about the Digitalmars-d-learn
mailing list