title: finding first three maximum element and their index of a vector
body: <p>I have a vector which looks like this</p>
  
  <pre><code>[12,3,4,5,6,7,8,12]
  </code></pre>
  
  <p>I want to find the index and the value of first three maximum number.The maximum number can also repeat like above vector 12 repeats .</p>
  
  <p>I used </p>
  
  <blockquote>
    <p>which</p>
  </blockquote>
  
  <p>but it only returns index for one number how can this be done</p>
  
  <p><strong>The output</strong></p>
  
  <pre><code>[12,12,8]
  [1,8,7]
  </code></pre>
  
  <p>I also read this <a href="https://stackoverflow.com/questions/18450778/r-fastest-way-to-get-the-indices-of-the-max-n-elements-in-a-vector">Stack Overflow</a> but it did not help</p>