original_string: public function setSortOrder(Select $select, $sort)
      {
          if ($sort === '' || null === $sort || empty($sort)) {
              return $select;
          }
  
          $select->reset('order');
  
          if (is_string($sort)) {
              $sort = explode(' ', $sort);
          }
  
          $order = [];
  
          foreach ($sort as $column) {
              if (strchr($column, '-')) {
                  $column = substr($column, 1, strlen($column));
                  $direction = Select::ORDER_DESCENDING;
              } else {
                  $direction = Select::ORDER_ASCENDING;
              }
  
              // COLLATE NOCASE
              // fix the sort order to make case insensitive for sqlite database.
              if ('sqlite' == $this->getAdapter()->getPlatform()->getName()) {
                  $direction = 'COLLATE NOCASE ' . $direction;
              }
  
              $order[] = $column . ' ' . $direction;
          }
  
          return $select->order($order);
      }
code: public function setSortOrder(Select $select, $sort)
      {
          if ($sort === '' || null === $sort || empty($sort)) {
              return $select;
          }
  
          $select->reset('order');
  
          if (is_string($sort)) {
              $sort = explode(' ', $sort);
          }
  
          $order = [];
  
          foreach ($sort as $column) {
              if (strchr($column, '-')) {
                  $column = substr($column, 1, strlen($column));
                  $direction = Select::ORDER_DESCENDING;
              } else {
                  $direction = Select::ORDER_ASCENDING;
              }
  
              // COLLATE NOCASE
              // fix the sort order to make case insensitive for sqlite database.
              if ('sqlite' == $this->getAdapter()->getPlatform()->getName()) {
                  $direction = 'COLLATE NOCASE ' . $direction;
              }
  
              $order[] = $column . ' ' . $direction;
          }
  
          return $select->order($order);
      }
code_tokens: public function setSortOrder ( Select $ select , $ sort ) { if ( $ sort === '' || null === $ sort || empty ( $ sort ) ) { return $ select ; } $ select -> reset ( 'order' ) ; if ( is_string ( $ sort ) ) { $ sort = explode ( ' ' , $ sort ) ; } $ order = [ ] ; foreach ( $ sort as $ column ) { if ( strchr ( $ column , '-' ) ) { $ column = substr ( $ column , 1 , strlen ( $ column ) ) ; $ direction = Select :: ORDER_DESCENDING ; } else { $ direction = Select :: ORDER_ASCENDING ; } // COLLATE NOCASE // fix the sort order to make case insensitive for sqlite database. if ( 'sqlite' == $ this -> getAdapter ( ) -> getPlatform ( ) -> getName ( ) ) { $ direction = 'COLLATE NOCASE ' . $ direction ; } $ order [ ] = $ column . ' ' . $ direction ; } return $ select -> order ( $ order ) ; }
docstring: Sets sort order of database query
  
  @param Select $select
  @param string|array $sort
  @return Select
docstring_tokens: Sets sort order of database query