range_sortna function

Prepare for sorting and get range, number of NAs and unsortedness