MathGroup Archive 2000

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

Search the Archive

Q: how to rank a list of elements?


Dear all,

I would like to obtain the ranking of a list of elements. So I conduct 
the following procedure:

In[60]:=
pseudo = {15, 7, 15, 1}
pseudoSort = pseudo // Sort
ranks = Position[pseudoSort, #] & /@ pseudo
rmDuplicate[ranks] // Flatten

Out[60]=
{15, 7, 15, 1}
Out[61]=
{1, 7, 15, 15}
Out[62]=
{{{3}, {4}}, {{2}}, {{3}, {4}}, {{1}}}
Out[63]=
{3, 2, 4, 1}

However, there are two questions: 1) the ranking is not quite correct, in 
which the tie situation is not addressed well in my procedure. Is 
there any system defined function for this purpose? And, 2) the function 
rmDuplicate is written in procedural way, i.e., using For to remove 
duplicated elements, could someone help/show me using functional or rule 
way to design this function? Thanks for your help.

Wen-Feng


  • Prev by Date: Re: NestWhile
  • Next by Date: Re: NestWhile
  • Previous by thread: Re: Mathematica and 3D surface.
  • Next by thread: Re: Q: how to rank a list of elements?