median<T> static method
Returns the median of list, or 0 when empty.
Implementation
static double median<T>(Iterable<T> list, {num Function(T)? by}) {
if (list.isEmpty) return 0;
final values = (by != null ? list.map(by) : list.cast<num>()).toList()
..sort();
final mid = values.length ~/ 2;
if (values.length.isOdd) return values[mid].toDouble();
return (values[mid - 1] + values[mid]) / 2;
}