Explain how you would detect anomalies from a dataset.
Implement detect_anomalies(data) for a non-empty numeric list with at least four values. Use the 1.5 × IQR rule, where quartiles are medians of the lower and upper halves after sorting, excluding the overall median when the length is odd. Return the original indices of values below Q1 - 1.5 * IQR or above Q3 + 1.5 * IQR, in ascending order.
def detect_anomalies(data):