[erlang-bugs] lists:usort/2 documentation bug

Paul Mineiro <>
Wed Aug 13 00:02:34 CEST 2008


the documentation says:

"Returns a list which contains the sorted elements of List1 where all but
the first element of the elements comparing equal according to the
ordering function Fun have been deleted. Fun(A, B) should return true if A
comes before B in the ordering, false otherwise."

however, if one uses a fun that returns (A < B), one gets a bad result;
this is because equality is detected via Fun (A, B) and Fun (B, A) both
being true. so instead the fun should return (A =< B).  i would suggest
rephrasing as

"... should return true if A compares less than or equal to B in the
ordering, false otherwise".

-- p



More information about the erlang-bugs mailing list