www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - joiner random access range?

reply "bearophile" <bearophileHUGS lycos.com> writes:
Given a 2D array, I'd like to sort its items sequentially:


import std.stdio, std.algorithm, std.range;

void foo(int[][] m) {
     m.joiner.sort().writeln; // error
}
void main() {
     auto m = [[10, 2], [30, 4]];
     m.joiner.writeln;
     foo(m);
     m.joiner.writeln;
     // OK, but the matrix can have arbitrary many rows.
     chain(m[0], m[1]).sort();
     m.joiner.writeln;
}


Is it possible and reasonable for "joiner" to return a random 
access range in such cases (where the input is a random access 
range of random access ranges), so I can sort its items?

Bye,
bearophile
Nov 08 2014
parent "bearophile" <bearophileHUGS lycos.com> writes:
This was Issue 8405 opened by Jonathan M Davis two years ago, I 
have added my use cases:
https://issues.dlang.org/show_bug.cgi?id=8405

Bye,
bearophile
Nov 09 2014