nodes: 0, module; 1, function_definition; 2, function_name:resort_client_actions; 3, parameters; 4, block; 5, identifier:portal; 6, expression_statement; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, comment:# Sort the actions; 12, expression_statement; 13, if_statement; 14, comment:# Reset the actions to type info; 15, expression_statement; 16, comment:"""Resorts client action views
      """; 17, assignment; 18, assignment; 19, assignment; 20, assignment; 21, assignment; 22, identifier:missing; 23, comment:# Move the actions not explicitily sorted to the end; 24, block; 25, assignment; 26, identifier:sorted_actions; 27, list; 28, identifier:type_info; 29, call; 30, identifier:actions; 31, call; 32, identifier:missing; 33, call; 34, identifier:actions; 35, call; 36, expression_statement; 37, attribute; 38, identifier:actions; 39, string:"edit"; 40, string:"contacts"; 41, string:"view"; 42, comment:# this redirects to analysisrequests; 43, string:"analysisrequests"; 44, string:"batches"; 45, string:"samplepoints"; 46, string:"profiles"; 47, string:"templates"; 48, string:"specs"; 49, string:"orders"; 50, string:"reports_listing"; 51, attribute; 52, argument_list; 53, identifier:filter; 54, argument_list; 55, identifier:filter; 56, argument_list; 57, identifier:sorted; 58, argument_list; 59, call; 60, identifier:type_info; 61, identifier:_actions; 62, attribute; 63, identifier:getTypeInfo; 64, string:"Client"; 65, lambda; 66, attribute; 67, lambda; 68, attribute; 69, identifier:actions; 70, keyword_argument; 71, attribute; 72, argument_list; 73, identifier:portal; 74, identifier:portal_types; 75, lambda_parameters; 76, comparison_operator:act.id in sorted_actions; 77, identifier:type_info; 78, identifier:_actions; 79, lambda_parameters; 80, comparison_operator:act.id not in sorted_actions; 81, identifier:type_info; 82, identifier:_actions; 83, identifier:key; 84, lambda; 85, identifier:actions; 86, identifier:extend; 87, identifier:missing; 88, identifier:act; 89, attribute; 90, identifier:sorted_actions; 91, identifier:act; 92, attribute; 93, identifier:sorted_actions; 94, lambda_parameters; 95, call; 96, identifier:act; 97, identifier:id; 98, identifier:act; 99, identifier:id; 100, identifier:act; 101, attribute; 102, argument_list; 103, identifier:sorted_actions; 104, identifier:index; 105, attribute; 106, identifier:act; 107, identifier:id
code: def resort_client_actions(portal):
      """Resorts client action views
      """
      sorted_actions = [
          "edit",
          "contacts",
          "view", # this redirects to analysisrequests
          "analysisrequests",
          "batches",
          "samplepoints",
          "profiles",
          "templates",
          "specs",
          "orders",
          "reports_listing"
      ]
      type_info = portal.portal_types.getTypeInfo("Client")
      actions = filter(lambda act: act.id in sorted_actions, type_info._actions)
      missing = filter(lambda act: act.id not in sorted_actions, type_info._actions)
  
      # Sort the actions
      actions = sorted(actions, key=lambda act: sorted_actions.index(act.id))
      if missing:
          # Move the actions not explicitily sorted to the end
          actions.extend(missing)
  
      # Reset the actions to type info
      type_info._actions = actions