To sum only positive values, you do not need to sort your initial values, use thrust::transform_reduce:
template<typename T>
struct positive_value : public thrust::unary_function<T,T>
{
__host__ __device__ T operator()(const T &x) const
{
return x < T(0) ? 0 : x;
}
};
float result = thrust::transform_reduce(data.begin(), data.end(),
positive_value<float>(),
0,
thrust::plus<float>());