title: count before, after and between points in an ordered list
body: <p>I'm trying to create an algo that will compute several counts before, after and between certain points in an ordered list. Here my "certain points" are the y values which need to be appended to the x values and ordered. Here is a simpler illustration of what I'm trying to do.</p>
  
  <pre><code>x = [2,3,5,6,7,9]
  y = [1,4,10]
  
  # appending y to x and ordering gives us: 
  full_list = [1,2,3,4,5,6,7,9,10]
  </code></pre>
  
  <p>so for y = 1 the metrics would be computed non-programmatically by slicing the full_list as so:</p>
  
  <pre><code>num_between_before = len(full_list[0:0])
  0
  num_between_after = len(full_list[0:4])
  2
  num_before = len(full_list[0:0])
  0
  num_after = len(full_list[0:9])
  8
  </code></pre>
  
  <p>but of course I'm trying to do this programmatically for any list x which are always numeric and any list y which are also always numeric. Both x and y can be of any size but len(y) &lt; len(x). The full ordered list can have the y values distributed anywhere among the x values.</p>
  
  <p>programmatically the output might look like this:</p>
  
  <pre><code># y_val: (num_between_before, num_between_after, num_before, num_after)
  output:
  1:  (0, 2, 0, 8)
  4:  (2, 4, 3, 5)
  10: (4, 0, 8, 0)
  </code></pre>
  
  <p>Obviously I'm having trouble so here in my code so far:</p>
  
  <pre><code>x = [1434684599341,1434684606154,1434684607190,1434684613843,1434684677605,
       1434684704358,1434684708727,1434684724495,1434684758413,1434684782632]
  
  y = [1434471725039, 1434684613844, 1434684708728, 1434684782633]
  
  y.sort()
  
  for i in y:
      x.append(i)
  
  x.sort()
  
  idx = []
  for j in y:
      idx.append(x.index(j))   
  
  counter = 0
  
  for i, k in zip(idx, y):
  
      counter += 1
      if i == 0:
          before = len(x[i:i])
          after = len(x[i:conv_index[counter]]) - 1
          print before, after
      elif i == idx[-1]:
          before = len(x[i-counter:idx[counter-1]]) - 1
          after = len(x[i:i])
          print before, after
      else:
          before = len(x[i:idx[counter]])
          after = len(x[i:idx[counter]]) - 1
          print before, after
  </code></pre>