nodes: 0, module; 1, function_definition; 2, function_name:by_vol_id; 3, parameters; 4, block; 5, identifier:blocks; 6, default_parameter; 7, expression_statement; 8, expression_statement; 9, comment:# sort block by volume; 10, comment:# not reliable with multiple partitions (fifo); 11, for_statement; 12, return_statement; 13, identifier:slist; 14, None; 15, comment:"""Sort blocks by volume id
  
      Arguments:
      Obj:blocks -- List of block objects.
      List:slist     -- (optional) List of block indexes.
  
      Return:
      Dict -- blocks grouped in lists with dict key as volume id.
      """; 16, assignment; 17, identifier:i; 18, identifier:blocks; 19, block; 20, identifier:vol_blocks; 21, identifier:vol_blocks; 22, dictionary; 23, if_statement; 24, if_statement; 25, expression_statement; 26, boolean_operator; 27, block; 28, elif_clause; 29, comparison_operator:blocks[i].vid_hdr.vol_id not in vol_blocks; 30, block; 31, call; 32, identifier:slist; 33, comparison_operator:i not in slist; 34, continue_statement; 35, not_operator; 36, block; 37, attribute; 38, identifier:vol_blocks; 39, expression_statement; 40, attribute; 41, argument_list; 42, identifier:i; 43, identifier:slist; 44, attribute; 45, continue_statement; 46, attribute; 47, identifier:vol_id; 48, assignment; 49, subscript; 50, identifier:append; 51, attribute; 52, subscript; 53, identifier:is_valid; 54, subscript; 55, identifier:vid_hdr; 56, subscript; 57, list; 58, identifier:vol_blocks; 59, attribute; 60, subscript; 61, identifier:peb_num; 62, identifier:blocks; 63, identifier:i; 64, identifier:blocks; 65, identifier:i; 66, identifier:vol_blocks; 67, attribute; 68, attribute; 69, identifier:vol_id; 70, identifier:blocks; 71, identifier:i; 72, attribute; 73, identifier:vol_id; 74, subscript; 75, identifier:vid_hdr; 76, subscript; 77, identifier:vid_hdr; 78, identifier:blocks; 79, identifier:i; 80, identifier:blocks; 81, identifier:i
code: def by_vol_id(blocks, slist=None):
      """Sort blocks by volume id
  
      Arguments:
      Obj:blocks -- List of block objects.
      List:slist     -- (optional) List of block indexes.
  
      Return:
      Dict -- blocks grouped in lists with dict key as volume id.
      """
  
      vol_blocks = {}
  
      # sort block by volume
      # not reliable with multiple partitions (fifo)
  
      for i in blocks:
          if slist and i not in slist:
              continue
          elif not blocks[i].is_valid:
              continue
  
          if blocks[i].vid_hdr.vol_id not in vol_blocks:
              vol_blocks[blocks[i].vid_hdr.vol_id] = []
  
          vol_blocks[blocks[i].vid_hdr.vol_id].append(blocks[i].peb_num)
  
      return vol_blocks