List <object>的排序

时间:2016-04-11 09:28:48

标签: android sorting listobject

我需要按高到低排序产品&amp;它的价格从低到高。我通过使用以下代码完成了从低到高。但是不知道如何实现从高到低?

您的回答更受赞赏......

 public static Comparator<Restaurant_Beam> strPriceFilterL2H = new Comparator<Restaurant_Beam>() {

      @Override
        public int compare(Restaurant_Beam lhs, Restaurant_Beam rhs) {
            int CompareResult = 0;
            if (Config.L2HFilterClicked == "L2H") {
                CompareResult = (int) Math.round(Double.parseDouble(lhs.getIG_SALES_PRICE()) - Double.parseDouble(rhs.getIG_SALES_PRICE()));

            } 
//Used else if for H2L.But did not get it as perfect

else if (Config.L2HFilterClicked == "H2L") {
                CompareResult = (int) Math.round(Double.parseDouble(lhs.getIG_SALES_PRICE()) + Double.parseDouble(rhs.getIG_SALES_PRICE()));

            }
            return CompareResult;
        }
    };

0 个答案:

没有答案