docstr: Check sorting a repeated composite field using list.sort() arguments.
docstr_tok: ["Check","sorting","a","repeated","composite","field","using","list.sort","(",")","arguments","."]
code: def testRepeatedCompositeFieldSortArguments(self):
      """Check sorting a repeated composite field using list.sort() arguments."""
      message = unittest_pb2.TestAllTypes()
  
      get_bb = operator.attrgetter("bb")
      cmp_bb = lambda a, b: cmp(a.bb, b.bb)
      message.repeated_nested_message.add().bb = 1
      message.repeated_nested_message.add().bb = 3
      message.repeated_nested_message.add().bb = 2
      message.repeated_nested_message.add().bb = 6
      message.repeated_nested_message.add().bb = 5
      message.repeated_nested_message.add().bb = 4
      message.repeated_nested_message.sort(key=get_bb)
      self.assertEqual(
          [k.bb for k in message.repeated_nested_message],
          [1, 2, 3, 4, 5, 6],
      )
      message.repeated_nested_message.sort(key=get_bb, reverse=True)
      self.assertEqual(
          [k.bb for k in message.repeated_nested_message],
          [6, 5, 4, 3, 2, 1],
      )
      message.repeated_nested_message.sort(sort_function=cmp_bb)
      self.assertEqual(
          [k.bb for k in message.repeated_nested_message],
          [1, 2, 3, 4, 5, 6],
      )
      message.repeated_nested_message.sort(cmp=cmp_bb, reverse=True)
      self.assertEqual(
          [k.bb for k in message.repeated_nested_message],
          [6, 5, 4, 3, 2, 1],
      )
  
imports: import copy
  import math
  import operator
  import pickle
  import unittest
  from google.protobuf import unittest_import_pb2
  from google.protobuf import unittest_pb2
  from google.protobuf.internal import api_implementation
  from google.protobuf.internal import test_util
  from google.protobuf import message
label_desc: Use image node_id 18 for calling the MessageTest obj's underlying member method code with example usage: obj.testRepeatedCompositeFieldSortArguments() without return types