class_docstr: The :obj:`Layout` class id designed for processing a list of layout elements
  on a page. It stores the layout elements in a list and the related `page_data`,
  and provides handy APIs for processing all the layout elements in batch. `
  
  Args:
      blocks (:obj:`list`):
          A list of layout element blocks
      page_data (Dict, optional):
          A dictionary storing the page (canvas) related information
          like `height`, `width`, etc. It should be passed in as a
          keyword argument to avoid any confusion.
          Defaults to None.
class_docstr_tok: ["The",":","obj",":","`","Layout","`","class","id","designed","for","processing","a","list","of","layout","elements","on","a","page",".","It","stores","the","layout","elements","in","a","list","and","the","related","`","page_data","`",",","and","provides","handy","APIs","for","processing","all","the","layout","elements","in","batch",".","`","Args",":","blocks","(",":","obj",":","`","list","`",")",":","A","list","of","layout","element","blocks","page_data","(","Dict",",","optional",")",":","A","dictionary","storing","the","page","(","canvas",")","related","information","like","`","height","`",",","`","width","`",",","etc",".","It","should","be","passed","in","as","a","keyword","argument","to","avoid","any","confusion",".","Defaults","to","None","."]
docstr: Sort the list of blocks based on the given
  
  Args:
      key ([type], optional): key specifies a function of one argument that
      is used to extract a comparison key from each list element.
      Defaults to None.
      reverse (bool, optional): reverse is a boolean value. If set to True,
      then the list elements are sorted as if each comparison were reversed.
      Defaults to False.
      inplace (bool, optional): whether to perform the sort inplace. If set
      to False, it will return another object instance with _block sorted in
      the order. Defaults to False.
  
  Examples::
      >>> import layoutparser as lp
      >>> i = lp.Interval(4, 5, axis="y")
      >>> l = lp.Layout([i, i.shift(2)])
      >>> l.sort(key=lambda x: x.coordinates[1], reverse=True)
docstr_tok: ["Sort","the","list","of","blocks","based","on","the","given","Args",":","key","(","[","type","]",",","optional",")",":","key","specifies","a","function","of","one","argument","that","is","used","to","extract","a","comparison","key","from","each","list","element",".","Defaults","to","None",".","reverse","(","bool",",","optional",")",":","reverse","is","a","boolean","value",".","If","set","to","True",",","then","the","list","elements","are","sorted","as","if","each","comparison","were","reversed",".","Defaults","to","False",".","inplace","(","bool",",","optional",")",":","whether","to","perform","the","sort","inplace",".","If","set","to","False",",","it","will","return","another","object","instance","with","_block","sorted","in","the","order",".","Defaults","to","False",".","Examples",":",":",">",">",">","import","layoutparser","as","lp",">",">",">","i","=","lp.Interval","(","4",",","5",",","axis=","''","y","''",")",">",">",">","l","=","lp.Layout","(","[","i",",","i.shift","(","2",")","]",")",">",">",">","l.sort","(","key=lambda","x",":","x.coordinates","[","1","]",",","reverse=True",")"]
code: def sort(
      self, key=None, reverse=False, inplace=False
  ) -> Optional["Layout"]:
      """Sort the list of blocks based on the given
  
      Args:
          key ([type], optional): key specifies a function of one argument that
          is used to extract a comparison key from each list element.
          Defaults to None.
          reverse (bool, optional): reverse is a boolean value. If set to True,
          then the list elements are sorted as if each comparison were reversed.
          Defaults to False.
          inplace (bool, optional): whether to perform the sort inplace. If set
          to False, it will return another object instance with _block sorted in
          the order. Defaults to False.
  
      Examples::
          >>> import layoutparser as lp
          >>> i = lp.Interval(4, 5, axis="y")
          >>> l = lp.Layout([i, i.shift(2)])
          >>> l.sort(key=lambda x: x.coordinates[1], reverse=True)
  
      """
      if not inplace:
          return self.__class__(
              sorted(self._blocks, key=key, reverse=reverse),
              page_data=self.page_data,
          )
      else:
          self._blocks.sort(key=key, reverse=reverse)
  
imports: from typing import List, Union, Dict, Dict, Any, Optional
  from collections.abc import MutableSequence, Iterable
  from copy import copy
  import pandas
  from .base import BaseCoordElement, BaseLayoutElement
  from .layout_elements import Interval, Rectangle, Quadrilateral, TextBlock, ALL_BASECOORD_ELEMENTS, BASECOORD_ELEMENT_NAMEMAP, BASECOORD_ELEMENT_INDEXMAP
label_desc: Use image node_id 15 for calling the Layout obj's underlying member method code with example usage: obj.sort(key, reverse, inplace) and returns: self