K
Knute Johnson
I've got a question about how to create a Comparator that I can use to
keep a sorted list of objects. The sort fields would be a code that is
not something to be sorted directly and a String that I would want
alphabetical. I would have a list of the codes and that list would be
in the sorted order. What I want to do is put the data in order
according to the list of codes and the other String.
The codes are actually going to be a 3 letter String. For example the
codes could be;
XAB
AJC
BQP
RST
and the data would be a code String and another String to sort
alphabetically.
XAB San Francisco
BQP Alabama
XAB Houston
AJC Montreal
I want the data sorted in this order:
XAB Houston
XAB San Francisco
AJC Montreal
BQP Alabama
Any simple ideas on how to design the Comparator?
Thanks,
keep a sorted list of objects. The sort fields would be a code that is
not something to be sorted directly and a String that I would want
alphabetical. I would have a list of the codes and that list would be
in the sorted order. What I want to do is put the data in order
according to the list of codes and the other String.
The codes are actually going to be a 3 letter String. For example the
codes could be;
XAB
AJC
BQP
RST
and the data would be a code String and another String to sort
alphabetically.
XAB San Francisco
BQP Alabama
XAB Houston
AJC Montreal
I want the data sorted in this order:
XAB Houston
XAB San Francisco
AJC Montreal
BQP Alabama
Any simple ideas on how to design the Comparator?
Thanks,