On 11/14/14 7:47 PM, Meta wrote:
On Saturday, 15 November 2014 at 00:45:11 UTC, Meta wrote:
On Saturday, 15 November 2014 at 00:33:11 UTC, Nordlöw wrote:
Is there a functional variant of std.algorithm.sort, say sorted, that
returns a sorted copy of its input use typically as

   const y = x.sorted;

?

If not any recommendations on its implementation?

`sort` returns a SortedRange, so sort is the function you're looking for.

Sorry, and if you want a copy, just add a `.array` on the end to create
a new array from the returned range.

err... this isn't what you want. That will sort the range, and then make a copy of the sorted range as an array.

Note, there isn't any generic way to say "give me a copy of this range, as the same type." array is probably the best you will get. Just make sure you call it *before* you sort, unless you want both ranges sorted :)

-Steve

Reply via email to