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);
    }