title: Return indices instead of value
body: <p>The following script returns <strong>tuple of sorted nodes</strong>(&quot;text&quot;, bounding box dimensions) i.e</p>
  <blockquote>
  <p>Tuple[Tuple[graphanno.Node,...],...],
  where</p>
  </blockquote>
  <blockquote>
  <p>Tuple[graphanno.Node,..]
  represents a line.</p>
  </blockquote>
  <p>But, i want to return the tuple of <strong>indices of sorted nodes</strong> i.e</p>
  <blockquote>
  <p>Tuple[Tuple[int,...],...],</p>
  </blockquote>
  <p>Following is the script that sorts nodes from left to right and returns tuple of sorted nodes.</p>
  <pre><code>def sort_nodes_into_lines(
      nodes: Iterable[graphanno.Node],
  ) -&gt; Tuple[Tuple[graphanno.Node, ...], ...]:
      &quot;&quot;&quot;
      Merge nodes that belong to one line.
  
      The algorithm does the following:
      1. Sort nodes by x-coordinate.
      2. Iterate through them and merge those that are close in x- and have
         overlap in y-direction to lines.
      3. If the current node does not belong to a previously seen line,
         start a new line from the node.
  
      Parameters
      ----------
      nodes
          The nodes that shall be sorted.
  
      Returns
      -------
      Tuple[Tuple[graphanno.Node,...],...]
          A tuple of the nodes sorted.
      &quot;&quot;&quot;
      nodes_sorted = sorted(nodes, key=lambda node: node.box.origin_x)
      reference, *remainder = nodes_sorted
      lines: Dict[graphanno.Node, List[graphanno.Node]] = {reference: [reference]}
      for node_idx, node in enumerate(remainder, start=1):
          is_matched = False
          for reference, line in lines.items():
              if _has_sufficient_y_overlap(reference, node):
                  *_, last_in_row = line
                  if _in_x_proximity(last_in_row, node):
                      line.append(node)
                      is_matched = True
                      break
          if not is_matched:
              lines[node] = [node]
      return tuple(
          sorted(
              (tuple(line) for line in lines.values()),
              key=_get_line_origin_x,
          )
      )
  
  
  def _get_line_origin_x(nodes: Sequence[graphanno.Node]) -&gt; int:
      &quot;&quot;&quot;Find min value of y coordinate of the origin of the bounding box.&quot;&quot;&quot;
      return min(node.box.origin_y for node in nodes)
  </code></pre>
  <p>Any help would be appreciated!</p>
  <p>Thank you!</p>