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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T07:37:10+00:00 2026-06-08T07:37:10+00:00

I think this may be a duplicate question. But couldn’t find the answer for

  • 0

I think this may be a duplicate question. But couldn’t find the answer for my requirement.

I have a list of names (String) such as

Merill, Gopi, kamal, orange, white

I need to do something to get the list in ascending order using collections like the following

Gopi, kamal, Merill, orange, white

Is it possible to get the list in alphabeticalorder?

Can anyone please tell how to sort this using collections?

(Please provide a solution before closing this questiona as duplicate)

  • 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-08T07:37:12+00:00Added an answer on June 8, 2026 at 7:37 am

    I know your trying to sort it using Collections, but here’s a simple way:

    public static void main(String[] args) throws ParseException {
        String[] values = new String[] {"Some item", "another item", "1 last more", "nevermind", "this is different"};
        System.out.println("Before: " + Arrays.toString(values));
        Arrays.sort(values, new Comparator<String>() {
            @Override
            public int compare(String arg0, String arg1) {
                return arg0.compareTo(arg1);
            }
        });
        System.out.println("After: " + Arrays.toString(values));
    }
    

    And this is outputted:

    Before: [Some item, another item, 1 last more, nevermind, this is different]

    After: [1 last more, Some item, another item, nevermind, this is different]

    The array is sorted numerical/other first, then capital-alphabetical, then lowercase-alphabetical

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

Sidebar

Related Questions

Hopefully this question isn't as subjective as I think it may be. I have
I think this could be a very easy question for you. But I have
I realise this may be a duplicate, but I have searched through many forums
I'm slightly worried that this may be a duplicate, but I have searched the
You may think this question is the exact duplicate of Running two projects at
This question may seem like a duplicate, but I just ran in to this
First, this may be marked as duplicate question, but the other questions were not
Possible Duplicate: Search and replace inside an associative array I think this may have
I think this may be relatively straight forward. I have a rewrite rule that
Instead of posting in Angular mailing list, I think this may be more of

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.