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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T23:31:48+00:00 2026-06-08T23:31:48+00:00

how to sort variables X and negated varibles X’ alphabetic which are saved as

  • 0

how to sort variables X and negated varibles X’ alphabetic which are saved as string in Java?

Example: String string = "B*A'*D*H'"; result must
         String sortedString="A'*B*D*H'";
  • 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-08T23:31:51+00:00Added an answer on June 8, 2026 at 11:31 pm

    are the variables always separated with * ?
    In that case it’d be very simple:

        String in = "B*A'*D*H'";
        String[] vars = in.split("\\*");
    
        Arrays.sort(vars);
    
        // Java is missing a simple php-like join function ;-(
        StringBuilder sorted = new StringBuilder();
        for(String s: vars){
            sorted.append(s);
            sorted.append("*");
        }
        sorted.deleteCharAt(sorted.length()-1);
    

    and you’re done 😉

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

Sidebar

Related Questions

I am learning about how Arrays.sort(...) works in Java. Why are variables: temp and
The following algorithm can sort three variables x , y and z of type
In Java I am wondering how to sort vectors of vectors on a particular
I'm have an NSArray that I need to sort based on variables that are
hello I want to sort(ascending) some numbers stored in different variables(like int a=50,int b=60,
So I want to create variables by looping through some sort of name assigning
I have 2 variables each containing a number (integer). I would like to sort
I would like to know which is the best way to sort table columns
Is there any way to sort alphabetically two strings variables in a JSP, for
Is there a way to use variables of some sort in an apache httpd.conf

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.