median static method
Returns the median of values, or 0 if empty.
Implementation
static double median(Iterable<num> values) {
if (values.isEmpty) return 0;
final sorted = [...values]..sort();
final mid = sorted.length ~/ 2;
if (sorted.length.isOdd) return sorted[mid].toDouble();
return (sorted[mid - 1] + sorted[mid]) / 2;
}