MathGroup Archive 2007

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

Search the Archive

Re: Ordering function weird?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg82673] Re: [mg82645] Ordering function weird?
  • From: DrMajorBob <drmajorbob at bigfoot.com>
  • Date: Sun, 28 Oct 2007 03:59:32 -0500 (EST)
  • References: <14809680.1193491087839.JavaMail.root@m35>
  • Reply-to: drmajorbob at bigfoot.com

Ordering works exactly the same way on both x and y; I have no idea what 
you think is different.

y = {1, 2, 7, 8, 9, 1, 2}
Ordering@y
y[[Ordering@y]]
Sort@y

{1, 2, 7, 8, 9, 1, 2}

{1, 6, 2, 7, 3, 4, 5}

{1, 1, 2, 2, 7, 8, 9}

{1, 1, 2, 2, 7, 8, 9}

Ordering@y gives the positions, in y, of the elements of Sort@y. The first  
element of Sort@y (1) is the first element of y, the second element of  
Sort@y (also 1) is the 6th element of y, the third element of Sort@y (2) 
is the 2nd element of y, the fourth element of Sort@y (2 again) is the 7th  
element of y, and so on.

Bobby

On Sat, 27 Oct 2007 04:59:25 -0500, Claus <claus.haslauer at web.de> wrote:

> Hi,
> say I've got two sets of number, x and y, which I want to rank. See the
> example below. I totally expect and want the result of Ordering[x]. But
> I neiter understand nor expect the result of Ordering[y]. Both Sort[x]
> and Sort[y] are ok.
> Can anybody explain to me Ordering[y]?
> Thanks,
> Claus
>
>
> In[3]:= x = {1, 2, 3, 6, 10, 3, 4}
> y = {1, 2, 7, 8, 9, 1, 2}
>
> Out[3]= {1, 2, 3, 6, 10, 3, 4}
>
> Out[4]= {1, 2, 7, 8, 9, 1, 2}
>
> In[5]:= Sort[x]
> Sort[y]
>
> Out[5]= {1, 2, 3, 3, 4, 6, 10}
>
> Out[6]= {1, 1, 2, 2, 7, 8, 9}
>
> In[7]:= Ordering[x]
> Ordering[y]
>
> Out[7]= {1, 2, 3, 6, 7, 4, 5}
>
> Out[8]= {1, 6, 2, 7, 3, 4, 5}
>
>



-- 

DrMajorBob at bigfoot.com


  • Prev by Date: Re: Mathematica not considering an assumption
  • Next by Date: Re: Errant post?
  • Previous by thread: Re: Ordering function weird?
  • Next by thread: Re: Ordering function weird?