package com.yfd.platform.utils;

import java.util.Comparator;
import java.util.List;
import java.util.Map;

public class CustomComparator implements Comparator<Map> {
    private List<String> orderList;

    public CustomComparator(List<String> orderList) {
        this.orderList = orderList;
    }

    @Override
    public int compare(Map map1, Map map2) {
        // 获取map1和map2中需要比较的字段的值
        String value1 = map1.get("pointcode").toString();
        String value2 = map2.get("pointcode").toString();

        // 获取value1和value2在orderList中的索引
        int index1 = orderList.indexOf(value1);
        int index2 = orderList.indexOf(value2);

        // 比较索引，返回比较结果
        return Integer.compare(index1, index2);
    }
}