Bug 8342 – Truly sorted output for topNCopy(zip())?
Status
RESOLVED
Resolution
INVALID
Severity
enhancement
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-07-03T13:18:02Z
Last change time
2017-08-28T09:06:21Z
Assigned to
No Owner
Creator
bearophile_hugs
Comments
Comment #0 by bearophile_hugs — 2012-07-03T13:18:02Z
Related to Issue 8341
I think in this case topNCopy should be able to generate a truly sorted output (instead of a heap):
import std.stdio, std.algorithm, std.range, std.typecons;
void main() {
auto a = [10, 20, 30];
auto b = ["c", "b", "a"];
Tuple!(int, string)[4] sorted_ab;
writeln(a, " ", b);
topNCopy!q{a > b}(zip(a, b), sorted_ab[], true); // error
topNCopy!q{a > b}(zip(a, b), sorted_ab[]); // OK
writeln(a, " ", b);
}
Comment #1 by razvan.nitu1305 — 2017-08-28T09:06:21Z
It can sort the output if you pass Yes.sortOutput as the third and final argument. Closing as invalid