Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2000

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

Search the Archive

Q: how to rank a list of elements?

  • To: mathgroup at
  • Subject: [mg23105] Q: how to rank a list of elements?
  • From: d8442803 at (Wen-Feng Hsiao)
  • Date: Wed, 19 Apr 2000 02:30:40 -0400 (EDT)
  • Organization: NSYSU
  • Sender: owner-wri-mathgroup at

Dear all,

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

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

{15, 7, 15, 1}
{1, 7, 15, 15}
{{{3}, {4}}, {{2}}, {{3}, {4}}, {{1}}}
{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.


  • 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?