title: Random weighted choice
body: <p>I have data like this:</p>
  
  <pre><code>d = (
    (701, 1, 0.2),
    (701, 2, 0.3),
    (701, 3, 0.5),
    (702, 1, 0.2),
    (702, 2, 0.3),
    (703, 3, 0.5)
  )
  </code></pre>
  
  <p>Where (701, 1, 0.2) = (id1, id2, priority)</p>
  
  <p>Is there a pretty way to choose id2 if I know id1, using priority?</p>
  
  <p>Func(701) should return: <br>
  &nbsp;&nbsp;1 - in 20% cases<br>
  &nbsp;&nbsp;2 - 30%<br>
  &nbsp;&nbsp;3 - 50%<br></p>
  
  <p>Percent will be rough of course</p>