I will try thinking before posting next time.

Maybe it's time to call it a day. :)

/Uffe

On Tue, 3 Jun 2003, Erik Reitsma (ETM) wrote:

>> I encountered some surprising results when using

>> lists:sort/2. Given a list [{P,R}], I wanted a list sorted

>> on P for all P < 3, and sorted on R for the remainder.

>

>What result would you like when you compare {P1,R1} and {P2,R2}, and P1<3 and P2>=3? And what if P1>=3 and P2<3? It looks like you have not specified this.

>

>> lists:sort(

>> fun({P1,_}, {P2,_}) when P1 < 3 ->

>> P1 < P2;

>> ({_,R1}, {_,R2}) ->

>> R1 < R2

>> end, L).

>

>If this function even anti-symmetrical? Consider X1={1,10} and X2={4,9}. Then F(X1,X2) = true and F(X2,X1) = true. Your function should be such, that F(A,B) = not F(B,A) for all A and B.

>

>When you have defined the relation you want, I think you will be able to find a fun that really implements that relation.

>

>*Erik.

>

--

Ulf Wiger, Senior Specialist,

/ / / Architecture & Design of Carrier-Class Software

/ / / Strategic Product & System Management

/ / / Ericsson AB, Connectivity and Control Nodes