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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:21:30+00:00 2026-05-26T01:21:30+00:00

I have a list of String characters, They are mix characters that includes special

  • 0

I have a list of String characters, They are mix characters that includes special characters too. I want to know how to sort them ascendingly ?

updated
example
aplha1.jpg
aplha10.jpg
2.jpg
3.jpg
4.jpg
aplha5.jpg

  • 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-26T01:21:31+00:00Added an answer on May 26, 2026 at 1:21 am

    I hope this will work for you.

    public class AlphanumericSorting implements Comparator<String> {
    
        public int compare(String firstObjToCompare, String 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;
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have List[(String,String)] and I need to sort them by the 2nd value and
I have a list of string values that I want add to a hashtable
I have a List of String objects that are pipe delimited. something like this:
I have a list of string like: s = [(abc,bcd,cde),(123,3r4,32f)] Now I want to
I have a list: List(Of String) I want to filter it with LINQ. I
I have a list of string that I am writing out to a CSV
I have a string list (TStrings) that has a couple thousand items in it.
I have some input string with characters and list of string. What I need
I have a list of legal characters and I want to remove all others
I have 2 collections of caracter string ex: List<string> one = new List<string>; one.Add(a);

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.