[Issue 8469] isSorted fails with predicate "a.length < b.length ? true : a < b"

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Jul 30 06:49:01 PDT 2012


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


Andrei Alexandrescu <andrei at metalanguage.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrei at metalanguage.com


--- Comment #1 from Andrei Alexandrescu <andrei at metalanguage.com> 2012-07-30 06:48:57 PDT ---
That's quite a pickle. The predicate is not a valid sorting relation because
according to it both "_20" < "_100" and "_100" < "_20" are true (so it's not
antisymmetric). That's how isSorted operates - it compares adjacent elements
with the predicate in swapped order.

We could make isSorted work with broken predicates (at a performance cost for
everyone), but then people may think if that works sort should works too with
such predicates etc. etc.

Best we can is include an assert in isSorted that catches bad predicates in
debug builds. Thoughts?

-- 
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