I was wondering if there was a way to find duplicate elements in an arraylist. For more context of what I'm trying to do, I have an arraylist of strings. The strings each contain information about an MP3 file. They have a title, composer, and running time seperated by a '&' character (e.g. Friday&Rebecca Black&666).
The arraylist has already been quicksorted according to the running times. However, I also need to sort the arraylist so that if the running times for songs are equal they should be put into lexicographic order on the title, and then on the composer if the titles are equal as well.
I want to be able to find duplicate running times in the arraylist so that I can use the compareTo
method to sort alphabetically like I need to. I have already implemented methods getTime
, getTitle
, getComposer
that extract the relevant information from the overall strings. Is there a way I could do this in a new method such as alphabetical
, or even better is there a way I could incorporate it into my quicksort algorithm so I don't have to search through the sorted arraylist again?
Thanks.