code: def by_type(blocks, slist=None):
      
  
      layout = []
      data = []
      int_vol = []
      unknown = []
      
      for i in blocks:
          if slist and i not in slist:
              continue
  
          if blocks[i].is_vtbl and blocks[i].is_valid:
              layout.append(i)
  
          elif blocks[i].is_internal_vol and blocks[i].is_valid:
              int_vol.append(i)
  
          elif blocks[i].is_valid:
              data.append(i)
  
          else:
              unknown.append(i)
  
      return layout, data, int_vol, unknown
docs: Sort blocks into layout, internal volume, data or unknown
  
      Arguments:
      Obj:blocks   -- List of block objects.
      List:slist   -- (optional) List of block indexes.
  
      Returns:
      List:layout  -- List of block indexes of blocks containing the
                      volume table records.
      List:data    -- List of block indexes containing filesystem data.
      List:int_vol -- List of block indexes  containing volume ids 
                      greater than UBI_INTERNAL_VOL_START that are not
                      layout volumes.
      List:unknown -- List of block indexes of blocks that failed validation
                      of crc in ed_hdr or vid_hdr.