I have the array of array values such as-
Object[] = [[0.25, "green"],[1.0, "red"],[0.25,"Amber"]];
how to sort it based on float values, my expected output will be-
Object[] = [[0.25,"green"],[0.25,"Amber"],[1.0,"Red"]];
i am implementing below code. I am trying to Assign map values into object[] array and adding to list.
Object[] getRiskMeterColor(float val1, String val2) {
Object[] obj = { val1, val2 };
return obj;
}
//This block of code is for Meter display if no values present
public List<Object[]> getRiskMeterChartForZeroValue(List<RiskConfigTableData> classRangesList){
List<Object[]> riskMeterColor = new ArrayList<Object[]>();
Map<String, String> riskClassList = new TreeMap<String,String>();
Map<String, Float> weightForLabel = new TreeMap<String,Float>();
float riskWeight = 0;
if(classRangesList != null && !classRangesList.isEmpty()){
if(riskClassList != null && weightForLabel != null){
for(Entry<String, String> colorMap : riskClassList.entrySet()){
for(Entry<String, Float> weightMap : weightForLabel.entrySet()){
if(colorMap.getKey().equalsIgnoreCase(weightMap.getKey())){
riskMeterColor.add(getRiskMeterColor(weightMap.getValue() / 100, colorMap.getValue()));
}
}
}
}
}
return riskMeterColor;
}
here i am converting that list to array so the values in side array is not coming in ascending order as shown above.
List<Object[]> riskMeterColorList =
getRiskMeterChartForZeroValue(classRangesList);
if (riskMeterColorList != null) {
Object[] userArray = riskMeterColorList.toArray(new
Object[riskMeterColorList.size()]);
}