original_string: public static function construct_order_by($cols, $textsortcols=array()) {
          global $DB;
          $bits = array();
  
          foreach ($cols as $column => $order) {
              if (in_array($column, $textsortcols)) {
                  $column = $DB->sql_order_by_text($column);
              }
              if ($order == SORT_ASC) {
                  $bits[] = $column . ' ASC';
              } else {
                  $bits[] = $column . ' DESC';
              }
          }
  
          return implode(', ', $bits);
      }
code: public static function construct_order_by($cols, $textsortcols=array()) {
          global $DB;
          $bits = array();
  
          foreach ($cols as $column => $order) {
              if (in_array($column, $textsortcols)) {
                  $column = $DB->sql_order_by_text($column);
              }
              if ($order == SORT_ASC) {
                  $bits[] = $column . ' ASC';
              } else {
                  $bits[] = $column . ' DESC';
              }
          }
  
          return implode(', ', $bits);
      }
code_tokens: public static function construct_order_by ( $ cols , $ textsortcols = array ( ) ) { global $ DB ; $ bits = array ( ) ; foreach ( $ cols as $ column => $ order ) { if ( in_array ( $ column , $ textsortcols ) ) { $ column = $ DB -> sql_order_by_text ( $ column ) ; } if ( $ order == SORT_ASC ) { $ bits [ ] = $ column . ' ASC' ; } else { $ bits [ ] = $ column . ' DESC' ; } } return implode ( ', ' , $ bits ) ; }
docstring: Prepare an an order by clause from the list of columns to be sorted.
  @param array $cols column name => SORT_ASC or SORT_DESC
  @return SQL fragment that can be used in an ORDER BY clause.
docstring_tokens: Prepare an an order by clause from the list of columns to be sorted .