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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:42:38+00:00 2026-05-26T16:42:38+00:00

I am using the following java code to sort the values: – Collections.sort(values); It

  • 0

I am using the following java code to sort the values: –

 Collections.sort(values);

It is working correctly except that it is sorting as follows: –
1 10 2 3 4

I need it to sort as follows: –
1 2 3 4 10

  • 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-26T16:42:39+00:00Added an answer on May 26, 2026 at 4:42 pm

    You are sorting Strings. You can change values to store a subclass of Number or implement your own Comparator to pass as the segment argument of the sort method which will do a “natural sort.”

    See this question for more details: Natural sort order string comparison in Java – is one built in?

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

Sidebar

Related Questions

We try to convert from string to Byte[] using the following Java code: String
I am trying to mock java.awt.Toolkit.beep() using JMockit Expectations. I have the following code
I am using SQLite in Java code through Zentus . I need to map
I want to install .air file using my java code.I am currently using following
I am using following regular expression my java code. ^.*(?=.{6,20})(?=.*[a-z].*[a-z])(?=.*[A-Z])(?=.*[0-9]).*$ When I am trying
I'm using the following java code to upload a multi-part image to an ASMX
I'm trying the following Java code to shut down Windows operating system. I'm using
I have the following issue using java 1.4 I try to display a very
In Java, we're using the following package to programmatically create excel documents: org.apache.poi.hssf If
In an app we are calculating a SHA1Hmac in java using the following: SecretKey

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.