I am studying Java and sorting.
I have a question about tracking the index number for duplicate values.
For example, we have table and I put all data into the ArrayList, like this:
ArrayList = {FOO , AA, BOB, AA, BOB}
Index | Value
1 | FOO
2 | AA
3 | BOB
4 | AA
5 | BOB
Now I would like to sort the data:
Index | Value
2 | AA
4 | AA
3 | BOB
5 | BOB
1 | FOO
Is there any way to keep unique index and sort data?
Thanks.
Create a class
and create
List<DataHelper>and write aComparatorto sortDataHelpers