randomAccessRange.sort() vs randomAccessRange.array.sort()

deed none at none.none
Mon Mar 4 14:47:46 PST 2013


Why randomAccessRange.array() before calling sort?
The std.algorithm.sort doc says: "Sorts a random-access range ..."


import std.algorithm, std.array;

long[] source = [2, 0, 1];

auto mapped = source.map!("a * 10");
assert (isRandomAccessRange!(typeof(mapped)));   // Passes. 
Implies possibility
                                                  // to to use 
std.algorithm.sort?

auto mappedThenSorted = mapped.sort();           // Error
auto mappedThenSorted = mapped.array.sort();     // Works (and 
used in examples)


What am I missing in the documentation?


More information about the Digitalmars-d-learn mailing list