public function buildSortFields($fields)
    {
        $sortFields = [];
        foreach ((array)$fields as $key => $value) {
            if (is_int($key)) {
                $sortFields[$value] = +1;
            } else {
                if ($value === SORT_ASC) {
                    $value = +1;
                } elseif ($value === SORT_DESC) {
                    $value = -1;
                }
                $sortFields[$key] = $value;
            }
        }
        return $sortFields;
    }
public function buildSortFields($fields)
    {
        $sortFields = [];
        foreach ((array)$fields as $key => $value) {
            if (is_int($key)) {
                $sortFields[$value] = +1;
            } else {
                if ($value === SORT_ASC) {
                    $value = +1;
                } elseif ($value === SORT_DESC) {
                    $value = -1;
                }
                $sortFields[$key] = $value;
            }
        }
        return $sortFields;
    }
public function buildSortFields ( $ fields ) { $ sortFields = [ ] ; foreach ( ( array ) $ fields as $ key => $ value ) { if ( is_int ( $ key ) ) { $ sortFields [ $ value ] = + 1 ; } else { if ( $ value === SORT_ASC ) { $ value = + 1 ; } elseif ( $ value === SORT_DESC ) { $ value = - 1 ; } $ sortFields [ $ key ] = $ value ; } } return $ sortFields ; }
Normalizes fields list for the MongoDB sort composition.
@param array|string $fields raw fields.
@return array normalized sort fields.
Normalizes fields list for the MongoDB sort composition .