original_string: protected static function distribute_policy_document_sortorder() {
          global $DB;
  
          $sql = "SELECT p.id, p.sortorder, MAX(v.timecreated) AS timerecentcreated
                    FROM {tool_policy} p
               LEFT JOIN {tool_policy_versions} v ON v.policyid = p.id
                GROUP BY p.id, p.sortorder
                ORDER BY p.sortorder ASC, timerecentcreated ASC";
  
          $rs = $DB->get_recordset_sql($sql);
          $sortorder = 10;
  
          foreach ($rs as $record) {
              if ($record->sortorder != $sortorder) {
                  $DB->set_field('tool_policy', 'sortorder', $sortorder, ['id' => $record->id]);
              }
              $sortorder = $sortorder + 2;
          }
  
          $rs->close();
      }
code: protected static function distribute_policy_document_sortorder() {
          global $DB;
  
          $sql = "SELECT p.id, p.sortorder, MAX(v.timecreated) AS timerecentcreated
                    FROM {tool_policy} p
               LEFT JOIN {tool_policy_versions} v ON v.policyid = p.id
                GROUP BY p.id, p.sortorder
                ORDER BY p.sortorder ASC, timerecentcreated ASC";
  
          $rs = $DB->get_recordset_sql($sql);
          $sortorder = 10;
  
          foreach ($rs as $record) {
              if ($record->sortorder != $sortorder) {
                  $DB->set_field('tool_policy', 'sortorder', $sortorder, ['id' => $record->id]);
              }
              $sortorder = $sortorder + 2;
          }
  
          $rs->close();
      }
code_tokens: protected static function distribute_policy_document_sortorder ( ) { global $ DB ; $ sql = "SELECT p.id, p.sortorder, MAX(v.timecreated) AS timerecentcreated
                    FROM {tool_policy} p
               LEFT JOIN {tool_policy_versions} v ON v.policyid = p.id
                GROUP BY p.id, p.sortorder
                ORDER BY p.sortorder ASC, timerecentcreated ASC" ; $ rs = $ DB -> get_recordset_sql ( $ sql ) ; $ sortorder = 10 ; foreach ( $ rs as $ record ) { if ( $ record -> sortorder != $ sortorder ) { $ DB -> set_field ( 'tool_policy' , 'sortorder' , $ sortorder , [ 'id' => $ record -> id ] ) ; } $ sortorder = $ sortorder + 2 ; } $ rs -> close ( ) ; }
docstring: Re-sets the sortorder field of the policy documents to even values.
docstring_tokens: Re - sets the sortorder field of the policy documents to even values .