docs: def linkage_group_ordering(linkage_records):
      """Convert degenerate linkage records into ordered info_frags-like records
      for comparison purposes.
  
      Simple example:
  
          >>> linkage_records = [
          ... ['linkage_group_1', 31842, 94039, 'sctg_207'],
          ... ['linkage_group_1', 95303, 95303, 'sctg_207'],
          ... ['linkage_group_2', 15892, 25865, 'sctg_308'],
          ... ['linkage_group_2', 41893, 41893, 'sctg_486'],
          ... ['linkage_group_3', 36614, 50582, 'sctg_516'],
          ... ]
          >>> ordering = linkage_group_ordering(linkage_records)
  
      Each key of the record is a newly-formed 'scaffold' (linkage group):
  
          >>> sorted(ordering.keys())
          ['linkage_group_1', 'linkage_group_2', 'linkage_group_3']
  
      Records are in the form [init_contig, frag_id, start, end, orientation].
      Since fragment ids are meaningless in non-HiC contexts a negative
      identifier is set so it is understood that region was added due to
      linkage data (-1 is for recovering data after first-pass polishing and -2
      is for sequence insertions after long read based polishing).
  
          >>> ordering['linkage_group_1']
          [['sctg_207', -3, 31842, 94039, 1], ['sctg_207', -3, 95303, 95303, 1]]
          >>> ordering['linkage_group_2']
          [['sctg_308', -3, 15892, 25865, 1], ['sctg_486', -3, 41893, 41893, 1]]
  
      Orientations are always set to 1 by default.
  
          >>> ordering['linkage_group_3']
          [['sctg_516', -3, 36614, 50582, 1]]
  
  
      """
  
      new_records = dict()
  
      for lg_name, linkage_group in itertools.groupby(
          linkage_records, operator.itemgetter(0)
      ):
          new_records[lg_name] = []
          for record in linkage_group:
              init_contig = record[-1]
              start = record[1]
              end = record[2]
  
              new_record = [init_contig, -3, start, end, 1]
  
              new_records[lg_name].append(new_record)
  
      return new_records