export.jl: sort stats functions.
quantile: handle NaNs by raising an error [#1142].

Also raise errors when the data array or quantile array is empty.
Added percentile function, but I'm not quite sure about this way
of defining it since I would expect 100 points.