code: def _weekmatrix_grouping(records, sections, split_interval):
      
  
      def _group_by_weektime(records, sections):
          for _, group in itertools.groupby(records, key=lambda r: bisect_right(sections, _find_weektime(r.datetime))):
              yield group
  
      section_records = _group_by_weektime(records, sections)
      section_lists = _extract_list_from_generator(section_records)
      section_indices = [bisect_right(sections, _find_weektime(r_list[0].datetime)) for r_list in section_lists]
      section_id = _find_day_section_from_indices(
          section_indices, split_interval)
      assert(len(section_lists) == len(section_id) and len(
          section_indices) == len(set(section_indices)))
  
      return section_lists, section_id
docs: Used to group a list of records across a week as defined by the supplied
      sections. Outputs a list containing records in each section and a list with
      info to identify those sections.
  
      Parameters
      ----------
      records : list
          The week of records to group across the different weekdays/sections.
      sections : list
          The list of sections for grouping. Each section will have an integer
          value stating the minutes away from midnight between Sunday and Monday.
      split_interval : int
          The interval in minutes for which each indicator is computed.