RE: Sort with -Infinity fails

*To*: mathgroup at smc.vnet.net*Subject*: [mg73860] RE: [mg73822] Sort with -Infinity fails*From*: "Jose Luis Gomez" <jose.luis.gomez at itesm.mx>*Date*: Fri, 2 Mar 2007 06:31:00 -0500 (EST)*Organization*: ITESM*References*: <200703011117.GAA28248@smc.vnet.net>

Dear Tom I guess the default sort criteria of Sort[] must take into account the = kind of expression. -Infinity is Not a number, and Sort[] just moves it after = the numbers. Something similar happens in the following example, where all numbers are placed before all the symbols (assume there are no values assigned to a, b and c): In[1]:= Sort[{c, 1, 5, 2, b, a}] Out[1]= {1, 2, 5, a, b, c} Therefore, the default behavior of Sort[] is more "computational" than "mathematical". However, you can override these behavior if you give the sort "criteria" as the second parameter of Sort[]: In[2]:= Sort[{-Infinity, -8, 5}, #1 < #2 &] Out[2]= {-Infinity, -8, 5} Here is another way to write the same: In[3]:= Sort[{-Infinity, -8, 5}, Function[{x1, x2}, x1 < x2]] Out[3]= {-Infinity, -8, 5} Regards from Mexico Jose http://homepage.cem.itesm.mx/lgomez/ -----Mensaje original----- De: Tom Aldenberg [mailto:Tom.Aldenberg at rivm.nl] Enviado el: Jueves, 01 de Marzo de 2007 05:17 a.m. Para: mathgroup at smc.vnet.net Asunto: [mg73822] Sort with -Infinity fails Dear MathGroup, Minus Infinity (-Infinity) is smaller than -8, but Sort does not sort it = as expected. Is there a Real minus Infinity? In[75]:= -Infinity < -8 Out[75]= True In[76]:= Sort[{-Infinity, -8, 5}] Out[76]= {-8, 5, -=1B$B!g=1B(B} Regards, Tom Aldenberg _________________________________________________________________________= ___ DISCLAIMER: http://www.rivm.nl/disclaimer.htm

**References**:**Sort with -Infinity fails***From:*Tom Aldenberg <Tom.Aldenberg@rivm.nl>