Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5954341
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:57:26+00:00 2026-05-22T17:57:26+00:00

I was wondering if there was a way to find duplicate elements in an

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T17:57:27+00:00Added an answer on May 22, 2026 at 5:57 pm

    You need to change the Comparator for your sort, so that in the event of a tie (equal running time) it looks at the title and composer. See:

     java.util.Collections.sort(List list, Comparator c) 
    

    particularly the principal method:

    int compare(Object o1, Object o2) 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a nice and clean way to find strings of capital letters of
I'm trying to find a way to not have code being duplicated when I
I was wondering if there is any way to find all the scripts associated
I was wondering if there is a way to find out the size of
Hi I was wondering if there is any way to find all the possible
I'm trying to find a way to duplicate a series of files/folders from one
I was wondering is there any system SP or any other way to find
I am wondering is there a way to find out memory allocations that dont
I'm wondering whether there is a way to find out whether a class is
I was wondering if there was some way in PHP to duplicate some of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.