MathGroup Archive 1997

[Date Index] [Thread Index] [Author Index]

Search the Archive

Sort[]

  • To: mathgroup at smc.vnet.net
  • Subject: [mg8540] Sort[]
  • From: Raya Firsov-Khanin <raya at mech.ed.ac.uk>
  • Date: Sat, 6 Sep 1997 23:16:09 -0400
  • Sender: owner-wri-mathgroup at wolfram.com

Hello,

I need to Sort[] lists that contain symbols.

I've noticed the following strange feature of Sort[].
Take a simple list
myList = {b, -b}; Sort gives a result in canonical order

Sort[myList]

{-b,b}  or 

Sort[myList, Less]

{b,-b}

Take now a simple list

myList1 = {-b, b}; Then, Sort gives the same correct result 

Sort[myList1]

{-b,b}

while Sort[] with Less argument gives incorrect result.

Sort[myList1, Less]
{-b,b}

Can someone explain what is the problem and how to deal with it?

I also need to work with list where symbols are declared Positive
(or Negative) etc. For instance, declare c Negative:

Sign[c]^=-1;
Then,

Sort[{-c, c}] should give {c, -c}

How to Sort those lists? Is there a way to use Sort[]
or I have to write my own function.


thanks,
            Raya Khanin
            University of Edinburgh


  • Prev by Date: conics and graphics
  • Next by Date: MatchQ
  • Previous by thread: Re: conics and graphics
  • Next by thread: Re: Sort[]