title: Getting Indices from Mathematica's Select
body: <p>How can I get the indices of a selection rather than the values. I.e.</p>
  
  <pre><code>list={3-&gt;4, 5-&gt;2, 1-&gt;1, 5-&gt;8, 3-&gt;2};
  Select[list, #[[1]]==5&amp;]; (* returns {5-&gt;2, 5-&gt;8} *)
  </code></pre>
  
  <p>I would like something like</p>
  
  <pre><code>SelectIndices[list, #[[1]]==5&amp;]; (* returns {2, 4} *)
  </code></pre>
  
  <p>EDIT: I found an answer to the immediate question above (see below), but what about sorting. Say I want to sort a list but rather than returning the sorted list, I want to return the indices in the order of the sorted list?</p>