nodes: 0, module; 1, function_definition; 2, function_name:list_items; 3, parameters; 4, block; 5, identifier:self; 6, default_parameter; 7, default_parameter; 8, expression_statement; 9, expression_statement; 10, if_statement; 11, return_statement; 12, identifier:sort_key; 13, None; 14, identifier:reverse; 15, False; 16, comment:"""Return a list of cart items.
  
          Parameters
          ----------
          sort_key : func
              A function to customize the list order, same as the 'key'
              argument to the built-in :func:`sorted`.
          reverse: bool
              If set to True, the sort order will be reversed.
  
          Returns
          -------
          list
              List of :attr:`item_class` instances.
  
          Examples
          --------
          >>> cart = Cart(request)
          >>> cart.list_items(lambda item: item.obj.name)
          [<CartItem: obj=bar, quantity=3>,
           <CartItem: obj=foo, quantity=1>,
           <CartItem: obj=nox, quantity=5>]
          >>> cart.list_items(lambda item: item.quantity, reverse=True)
          [<CartItem: obj=nox, quantity=5>,
           <CartItem: obj=bar, quantity=3>,
           <CartItem: obj=foo, quantity=1>]
  
          """; 17, assignment; 18, identifier:sort_key; 19, block; 20, identifier:items; 21, identifier:items; 22, call; 23, expression_statement; 24, identifier:list; 25, argument_list; 26, call; 27, call; 28, attribute; 29, argument_list; 30, attribute; 31, argument_list; 32, identifier:items; 33, identifier:sort; 34, keyword_argument; 35, keyword_argument; 36, attribute; 37, identifier:values; 38, identifier:key; 39, identifier:sort_key; 40, identifier:reverse; 41, identifier:reverse; 42, identifier:self; 43, identifier:items
code: def list_items(self, sort_key=None, reverse=False):
          """Return a list of cart items.
  
          Parameters
          ----------
          sort_key : func
              A function to customize the list order, same as the 'key'
              argument to the built-in :func:`sorted`.
          reverse: bool
              If set to True, the sort order will be reversed.
  
          Returns
          -------
          list
              List of :attr:`item_class` instances.
  
          Examples
          --------
          >>> cart = Cart(request)
          >>> cart.list_items(lambda item: item.obj.name)
          [<CartItem: obj=bar, quantity=3>,
           <CartItem: obj=foo, quantity=1>,
           <CartItem: obj=nox, quantity=5>]
          >>> cart.list_items(lambda item: item.quantity, reverse=True)
          [<CartItem: obj=nox, quantity=5>,
           <CartItem: obj=bar, quantity=3>,
           <CartItem: obj=foo, quantity=1>]
  
          """
          items = list(self.items.values())
          if sort_key:
              items.sort(key=sort_key, reverse=reverse)
          return items