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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:30:36+00:00 2026-06-17T11:30:36+00:00

I have this array storing the suffix of some URLs the user is adding:

  • 0

I have this array storing the suffix of some URLs the user is adding:

[U2, U3, U1, U5, U8, U4, U7, U6]

When I do this:

for (Map<String, String> map : getUrlAttachments()) {
            String tmpId = map.get("id"); //it receives the U2, in the 1st iteration, then U3, then U1,...
            if (tmpId.charAt(0) == 'U') {
                tmpId.charAt(1);//2, then 3, then 1,...
                String url = map.get("url");
                String description = map.get("description");
                URLAttachment attachment;
                String cleanup = map.get("cleanup");
                if (cleanup == null && url != null && description != null) {
                    attachment = new URLAttachmentImpl();
                    attachment.setOwnerClass(FileUploadOwnerClass.Event.toString());
                    attachment.setUrl(url);
                    attachment.setDescription(description);
                    attachment.setOwnerId(auctionHeaderID);
                    attachment.setUrlAttachmentType(URLAttachmentTypeEnum.EVENT_ATTACHMENT);
                    attachment.setDateAdded(new Date());
                    urlBPO.save(attachment);

            }

My problem:

I want to change this For condition by passing another list mapping the data sorted like [U1, U2, U3, U4, U5, U6, U7, U8].

I’d like your help to know what’s the best way I could do this.

I thought about creating an array listing the ids and then sort then, but I don’t know how exactly to sort alphanumeric strings in java.

  • 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-17T11:30:37+00:00Added an answer on June 17, 2026 at 11:30 am

    I decide to use the idea @Abu gave, but I adapted it:

    1. I check the ids of the urls the user is trying to add,
    2. I remove the alphabetic suffix in this id and then I create an ArrayList to store the numerical part of each id.
    3. I sort this ArrayList like @Abu taught me in his answer and then I verify for each id in this sorted ArrayList in the sequence it should be added..

      ArrayList <Integer> urlSorted = new ArrayList<Integer>();
      //sort the url ids
      for (Map<String, String> map : getUrlAttachments()) {
          String tmpId = map.get("id");
          if (tmpId.charAt(0) == 'U') {
              //gets the id, removing the prefix 'U'
              urlSorted.add( Integer.valueOf(tmpId.substring(1)));
          }
      }
      //sort the urlIds to check the sequence they must be added
      Collections.sort(urlSorted);
      //checks for each url id, compares if it's on the natural order of sorting to be added.
      for(Integer urlId: urlSorted) {
          for (Map<String, String> map : getUrlAttachments()) {
              String sortedId = "U"+urlId;
              String tmpId = map.get("id");
              //compare the ids to add the 1, then 2, then 3...
              if (map.get("id").equals(sortedId)) {
                          //code to save according to the sorted ids.
              }
           }
      }
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this array: string[,] productData = new string[5,7]; I bind it to a
I have this 4 Dimensional array to store String values which are used to
I have this string of numbers var array = 1,6,2,9,5 which is retrieved from
i have this code that will check the array contains the specific string and
Basically I have this string $str=word1 word2 word3; I need array( 'word1', 'word2', 'word3'
I have an array similar to this: array(2) { [0]=> array(2) { [code]=> string(2)
I have an array with this structure: array(4) { [0]=> array(x) { [0]=> string(x)London
If you have a string of 1,2,3,1,5,7 you can put this in an array
I have string that look like Array that fetched from other webservice like this
I have a string like this: TEST.DATA.Data.COR.Point,2;TEST.DATA.Data.COR.Point,5;TEST.DATA.Data.COR.Point,12;TEST.DATA.Data.COR.Point,12;TEST.DATA.Data.COR.WordTOFIND,18 I have a list of array with

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.