www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15420] New: topN(Range, Range) does not respect its less

https://issues.dlang.org/show_bug.cgi?id=15420

          Issue ID: 15420
           Summary: topN(Range, Range) does not respect its less predicate
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: lt.infiltrator gmail.com

=============
import std.algorithm;
import std.stdio;

void main() {
   int[] a = [ 5, 7, 2, 6, 7 ];
   int[] b = [ 2, 1, 5, 6, 7, 3, 0 ];
   topN!"a > b"(a, b);
   sort!"a > b"(a);
   assert(a == [ 7, 7, 7, 6, 6 ]);
}
=============

The above code fails on the assertion because topN has ignored the predicate
given to it.

--
Dec 07 2015