package com.ruoyi.common.utils;

import com.alibaba.fastjson2.JSONObject;

import java.text.Collator;
import java.util.Collections;
import java.util.List;
import java.util.Locale;

public class CommonUtils {

    /**
     * 使用中国汉字首字母排序，A-Z的顺序
     * @param data
     * @return
     */
    public static List<String> sortByChina(List<String> data){
        Collator collator = Collator.getInstance(Locale.CHINA);
        Collections.sort(data, collator);
        return data;
    }


    public static void normalRate(JSONObject o) {
        Integer val = o.getInteger("value");
        Double rate = o.getDouble("rate");
        if(null != val && null != rate && val > 0 && rate < 0.01) {
            o.put("rate", 0.1);
        }
    }
}
