nodes: 0, module; 1, function_definition; 2, function_name:sort_run; 3, parameters; 4, block; 5, identifier:run; 6, expression_statement; 7, comment:# Sort errors first, then by name. Also show errors that were manually; 8, comment:# approved, so the paging sort order stays the same even after users; 9, comment:# approve a diff on the run page.; 10, if_statement; 11, return_statement; 12, comment:"""Sort function for runs within a release."""; 13, comparison_operator:run.status in models.Run.DIFF_NEEDED_STATES; 14, block; 15, tuple; 16, attribute; 17, attribute; 18, return_statement; 19, integer:1; 20, attribute; 21, identifier:run; 22, identifier:status; 23, attribute; 24, identifier:DIFF_NEEDED_STATES; 25, tuple; 26, identifier:run; 27, identifier:name; 28, identifier:models; 29, identifier:Run; 30, integer:0; 31, attribute; 32, identifier:run; 33, identifier:name
code: def sort_run(run):
          """Sort function for runs within a release."""
          # Sort errors first, then by name. Also show errors that were manually
          # approved, so the paging sort order stays the same even after users
          # approve a diff on the run page.
          if run.status in models.Run.DIFF_NEEDED_STATES:
              return (0, run.name)
          return (1, run.name)