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 7769965
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T16:17:27+00:00 2026-06-01T16:17:27+00:00

I am multiple ArrayLists with custom objects that implement the Comparatorinterface. Its possible that

  • 0

I am multiple ArrayLists with custom objects that implement the Comparatorinterface. Its possible that these multiple lists have the same objects. My requirement is each list can have its own order

For eg:

list 1 can contain 4 objects Obj2, Obj4, Obj1, Obj3
list 2 can contain say 5 objects Obj4, Obj3 , Obj5 , Obj1 , Obj2

If I assign an id of (0,1,2,3,4) in List1 to each custom object and use the sort method on the ArrayList I think it will work for me if I have a single List.

But I cannot do that because the same objects will need to be in different order for List2. Is there a way I can use the comparator and depend on the Collections framework sorting for me instead of me having to maintain a separate order list for each ArrayList ?

Any help will be greatly appreciated.

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-06-01T16:17:29+00:00Added an answer on June 1, 2026 at 4:17 pm

    Write a custom comparator, then use Collections.sort(list, comparator). You can have two (or how ever many you need) comparators to allow you to sort your objects based on different parameters.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

multiple webapp running on same tomcat using same jvm. sometime, one webapp that have
I have an ArrayList that contains multiple String[] (String arrays). Each String[] contains a
I have multiple classes that are not allowed to modify each other's fields, but
I have an ArrayList of items that are linked to a custom Adapter. The
How can I split an ArrayList (size=1000) in multiple ArrayLists of the same size
We have multiple threads calling add(obj) on an ArrayList . My theory is that
How to implement a custom code whenever an item in a multiple choice list
What are different ways in which we can XML serialize multiple objects of same/different
Let's say I have multiple Objects to be stored: Person ------------ Employee ------------ Sales
I'm trying to serialize a custom class that needs to use multiple elements 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.