[erlang-bugs] lists:usort/2 documentation bug
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
"... should return true if A compares less than or equal to B in the
ordering, false otherwise".
More information about the erlang-bugs