[Issue 4948] std.algorithm.sort asserts unexpectedly with certain comparators

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Apr 22 09:59:39 PDT 2012


http://d.puremagic.com/issues/show_bug.cgi?id=4948


SomeDude <lovelydear at mailmetrash.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|WORKSFORME                  |


--- Comment #4 from SomeDude <lovelydear at mailmetrash.com> 2012-04-22 10:00:38 PDT ---
I'm sorry but I'm reopening the case: there is no reason for the sort to fail
if two elements are equal. A sort that fails in this case is broken.

Besides, as I've said before, it works with a multiplication or a division,
even with equals elements. It only fails with the atan2 function.

import std.stdio;
import std.typecons, std.algorithm, std.math;

void main()
{
    alias Tuple!(int, "x", int, "y") V;
    V[] vs = [V(6, 8), V(1, 2), V(6, 8), V(5,6)];    
    float arg(V v) { return (cast(float)v.y * cast(float)v.x); }
    bool order(V a, V b) { return arg(a) < arg(b); }
    writeln(sort!order(vs));
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list