I'm not that great when it comes to this sort of stuff, so excuse my stupidity. Nonetheless, I have an XML schema that contains various elements and one of the elements that I'm retrieving is referred to as 'Value' which is a double. Essentially, after I iterate through the schema to retrieve all the values, I'm converting them into a String to store them within a (AWT) generated list. I've been trying to get the values to sort and arrange the list then append the sorted values to the list again, but I seem to be failing miserably at it.
I've provided what I was trying to do down, but all that does is just place the values within square brackets and return them as how they originally are (unsorted). Would appreciate if someone can explain where I'm going wrong.
List<org.netbeans.xml.schema.sharesxml.SharePrice> CurrentShares = getAllShares();
Iterator itr = CurrentShares.iterator();
while(itr.hasNext() == true){
SharePrice sp;
sp = (SharePrice) itr.next();
Double value = sp.getValue();
String values = value.toString();
List<String> valuesList = new ArrayList<>(Arrays.asList(values.split("
")));
valuesList.sort(Comparator.comparing(String::toString));
Collections.sort(valuesList);
String val = valuesList.toString();
list5.add(val);
EDIT: So the current output looks like this:
Output image
The expected output just needs to re-arrange these numbers from highest to lowest order.
question from:
https://stackoverflow.com/questions/65881266/sorting-a-list-of-values-from-an-xml-schema 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…