def median_from_dict(total, count):
 pos = ((total - 1) / 2)
 for k in sorted(six.iterkeys(count)):
  if (pos < count[k]):
   return k
  pos -= count[k]

def median_from_dict ( total , count ) : pos = ( ( total - 1 ) / 2 ) for k in sorted ( six . iterkeys ( count ) ) : if ( pos < count [ k ] ) : return k pos -= count [ k ]
total is the number of requests made count is a dict {response_time: count} .