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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:05:51+00:00 2026-05-27T07:05:51+00:00

I decided to do server-side sorting. I have a HashMap with Objects (key is

  • 0

I decided to do server-side sorting. I have a HashMap with Objects (key is a String, value is an ItemDTO). These are loaded statically upon server start.

For every character (CharacterDTO) that has an amount of items (in this case ItemOnCharacterDTO) I need to be able to sort stuff. So my client sends a request for sorting the objects as well as some filter-data. What I now want to do is:

  1. get the full ItemDTOs based on the IDs saved in ItemOnCharacterDTOs
  2. add those ItemDTOs into a list
  3. sort the ItemDTOs inside that list (probably using a Comparator)
  4. create an Array of IDs (it corresponds to the sequence of the list of ItemDTOs after the sorting)
  5. discard the list of ItemDTOs that I’ve previously created, since I got the correct order after sorting already

My question is now: do I need to copy the ItemDTOs before adding them to the list in order to not interfere with several sortings going on at the same time?

I do change the order of ItemDTOs within the newly created list of ItemDTOs (step 2 above), but I don’t change the ItemDTOs themselves (hence they are static and within the HashMap I mentioned at the beginning).

Thank you for your help in advance!

  • 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-27T07:05:52+00:00Added an answer on May 27, 2026 at 7:05 am

    You only need to copy the individual objects if they are mutable i.e. if they might be changed in a way that would effect the sort order or filtering. In Java an array of Objects is actually an array of references to objects on the heap, so moving the references in the array has no effect on the underlying objects.

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

Sidebar

Related Questions

In my include_path on the server-side I have a reference to a pear directory,
I have two separate files that one is server-side JS. The other one is
So we decided to go with visual studio team foundation server for version control,
So I'm using this SQL Server with my application and I decided to display
I decided to learn C++ (I program in C at work), and I have
I am using Spring MVC on the server side, but in one of the
I have a client server application writter in C# .NET using Sockets. I often
I have a model pop extender control like: <cc1:ModalPopupExtender ID=basketPopUp runat=server PopupControlID=Panel1 PopupDragHandleControlID=PopupHeader Drag=true
I am writing a markdown compiler in Erlang for server-side use. Because it will
Well, I just started to work on server side scripting , I chose PHP,

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.