package factor_edb_series

// FactorEdbSeriesCorrelationMatrixValues 因子指标系列-相关性矩阵XY值
type FactorEdbSeriesCorrelationMatrixValues struct {
	XData int     `description:"X轴数据"`
	YData float64 `description:"Y轴数据"`
}

// FactorEdbSeriesCorrelationMatrixOrder 排序规则[0 1 2 3 -1 -2 -3]
type FactorEdbSeriesCorrelationMatrixOrder []FactorEdbSeriesCorrelationMatrixValues

func (a FactorEdbSeriesCorrelationMatrixOrder) Len() int {
	return len(a)
}

func (a FactorEdbSeriesCorrelationMatrixOrder) Swap(i, j int) {
	a[i], a[j] = a[j], a[i]
}

func (a FactorEdbSeriesCorrelationMatrixOrder) Less(i, j int) bool {
	// 非负数优先
	if a[i].XData >= 0 && a[j].XData < 0 {
		return true
	}
	if a[i].XData < 0 && a[j].XData >= 0 {
		return false
	}
	// 非负数升序排序
	if a[i].XData >= 0 {
		return a[i].XData < a[j].XData
	}
	// 负数按绝对值的降序排序（即数值的升序）
	return a[i].XData > a[j].XData
}
