sorting on second member of an object.
I have: an existing structure:
private Set<Rule> dAllRules = new HashSet<Rule>();
where the object Rule defined with five members
I have the existing code:
example of data:
Id1 = "ABC"
Id2 = "1"
Id3 = "hello1"
Id4 = "123"
Id5 = "5"
Id1 = "DEF"
Id2 = "3"
Id3 = "hello2"
Id4 = "124"
Id5 = "1"
if i print or access objects in dAllRules
might print object #1 or object #2 since HashSet is not sorted.
I need to have the above data sorted on the second member of the object.
so that output/access would always be object #1 or object #2.
In other words I want to have a structure that contains objects of type Rule
that are sorted by the object's second memeber (Id2).
What is the easiest way to do this? I can add a new structure if I want.