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

  • Home
  • SEARCH
  • 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 7886587
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:21:22+00:00 2026-06-03T05:21:22+00:00

I have two arrays: arrayA = {b,c,a} arrayB = {99,11,22} How do I sort

  • 0

I have two arrays:

arrayA = {"b","c","a"} 
arrayB = {"99","11","22"}

How do I sort them together so that arrayA = {"a","b","c"} and arrayB = {"22","99","11"}?

  • 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-03T05:21:24+00:00Added an answer on June 3, 2026 at 5:21 am

    I have made one alphanumeric sorting programm Check it out.

    import java.util.Arrays;
    import java.util.Comparator;
    
    public class AlphanumericSorting implements Comparator {
        public int compare(Object firstObjToCompare, Object secondObjToCompare) {
            String firstString = firstObjToCompare.toString();
            String secondString = secondObjToCompare.toString();
    
            if (secondString == null || firstString == null) {
                return 0;
            }
    
            int lengthFirstStr = firstString.length();
            int lengthSecondStr = secondString.length();
    
            int index1 = 0;
            int index2 = 0;
    
            while (index1 < lengthFirstStr && index2 < lengthSecondStr) {
                char ch1 = firstString.charAt(index1);
                char ch2 = secondString.charAt(index2);
    
                char[] space1 = new char[lengthFirstStr];
                char[] space2 = new char[lengthSecondStr];
    
                int loc1 = 0;
                int loc2 = 0;
    
                do {
                    space1[loc1++] = ch1;
                    index1++;
    
                    if (index1 < lengthFirstStr) {
                        ch1 = firstString.charAt(index1);
                    } else {
                        break;
                    }
                } while (Character.isDigit(ch1) == Character.isDigit(space1[0]));
    
                do {
                    space2[loc2++] = ch2;
                    index2++;
    
                    if (index2 < lengthSecondStr) {
                        ch2 = secondString.charAt(index2);
                    } else {
                        break;
                    }
                } while (Character.isDigit(ch2) == Character.isDigit(space2[0]));
    
                String str1 = new String(space1);
                String str2 = new String(space2);
    
                int result;
    
                if (Character.isDigit(space1[0]) && Character.isDigit(space2[0])) {
                    Integer firstNumberToCompare = new Integer(Integer
                            .parseInt(str1.trim()));
                    Integer secondNumberToCompare = new Integer(Integer
                            .parseInt(str2.trim()));
                    result = firstNumberToCompare.compareTo(secondNumberToCompare);
                } else {
                    result = str1.compareTo(str2);
                }
    
                if (result != 0) {
                    return result;
                }
            }
            return lengthFirstStr - lengthSecondStr;
        }
    
        public static void main(String[] args) {
            String[] alphaNumericStringArray = new String[] { "NUM10071",
                    "NUM9999", "9997", "9998", "9996", "9996F" };
    
            Arrays.sort(alphaNumericStringArray, new AlphanumericSorting());
    
            for (int i = 0; i < alphaNumericStringArray.length; i++) {
                System.out.println(alphaNumericStringArray[i]);
            }
    
        }
    
    }
    

    Here is the output:

    9996
    9996F
    9997
    9998
    NUM9999
    NUM10071

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

Sidebar

Related Questions

I have combined two arrays using array_merge, and now need to sort them alphabetically.
Let's say I have two arrays: int ArrayA[] = {5, 17, 150, 230, 285};
so I have two arrays. one of them looks like this (it's values or
If I have two parallel lists and want to sort them by the order
I have two arrays, one that is made up of NSDates and one that's
I have two arrays of animals (for example). $array = array( array( 'id' =>
i have two arrays like this first array Array ( [0228] => Array (
I have two arrays the first one has this structure Parameter Keys array array
I have two JavaScript arrays: var array1 = [Vijendra,Singh]; var array2 = [Singh, Shakya];
Suppose I have two arrays like the following: $arr2 = array(array(first, second), array(third, fourth));

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.