Stats: moved median to a new function to enable better algorithms. Refactored CSPL_Stats_median() to CSPL_Stats_median_sort()