Check if variable is set in filter

The variable you have named $query is actually the WP_Query instance having filters applied to it.

You can simply call its function get to retrieve query vars.

For example:

function votes( $where, $query )
{
    $sort = $query->get('sort');
    if (!empty($sort)
        $where .= " AND $sort >= votes";
    return $where;
}