def DetermineHotlistIssuePosition(issue, issue_ids):
  """Find position of an issue in a hotlist for a flipper.

  Args:
    issue: The issue PB currently being viewed
    issue_ids: list of issue_id's

  Returns:
    A 3-tuple (prev_iid, index, next_iid) where prev_iid is the
    IID of the previous issue in the total ordering (or None),
    index is the index that the current issue has in the sorted
    list of issues in the hotlist,
    next_iid is the next issue (or None).
  """

  prev_iid, next_iid = None, None
  total_issues = len(issue_ids)
  for i, issue_id in enumerate(issue_ids):
    if issue_id == issue.issue_id:
      index = i
      if i < total_issues - 1:
        next_iid = issue_ids[i + 1]
      if i > 0:
        prev_iid = issue_ids[i - 1]
      return prev_iid, index, next_iid
  return None, None, None