Here is how a case looks:
Case Name : addrun
You can't sort a Map. It is not designed like that. You can only sort a List. It is easy enough to put all the objects into a List and sort that. I presume you are already familiar with sorting.
But there is something odd here. You say you are putting the objects into a Map<String, String>. That does not seem right; those objects are not Strings at all. A priority is not a String, but it might be an element of an enum. And what are child nodes? Do you mean that each object has a priority field?
I think you might do well to reconsider the entire design of the objects you are trying to sort. And please tell us why you are putting them into a Map: what does the “K” mean and what does the “V” mean?
Freddie van wrote:I have constructed a program that takes an xml file parses the file and stores each case with it child nodes in a hashmap<string, string>.
Campbell's absolutely right. Your XML file contains data, and data are best represented as objects in Java.
You might find the StringsAreBad page worth reading.
Its the getTextContext function that returns everything in a string and the only way I have figured out how to get the values from the xml file without having to declare each instance.
Freddie van wrote:The only problem is the way to data is parsed is a string so there is no way around using it. Well as far as I can tell.
You receive the data as a String. That's fine. That doesn't mean you have to keep it as a String. As a first pass, you can define classes for each XML element. For instance, if you had something like this:
Then you should define at least a Person class and an Address class. You might want to just keep firstName, lastName, street, city, and state as Strings, but there are arguments for making them their own classes too. At the very least I'd make a State enum.
Then if the XML contains a bunch of person elements, you could create, for example a List<Person> in which to store them.
Freddie van der Neut wrote:Well for instance how would you enumerate state is the example you provided?
Rather than firing questions which sound like you simply want us to supply you with the code, why not have a look at the tutorials and see if you can't work it out for yourself?
If you run into trouble, come back with what you tried.
People will be much happier to help if you ShowSomeEffort (←click).