Question: How to find the second largest element in a list and its index?

  Hello: 
     We know The FindMaximalElement(L) function returns the largest element of the list L .
   My questions is  How do I find the second largest element in a list and its index?  
     Since there are so many lists to consider , Algorithmic Complexity may be as low as possible.
     More generally, we want to find the third-largest  element and so on.
     For instance, Given a list [3,2,3,6,8], we want to get 6 and 4 , since 6 is the  second largest element and 4 is its index. 
    Thank you in advance for your help.
  Licheng

Please Wait...