Languages
[Edit]
EN

Java - how to sort alphanumeric array of Strings - natural order sorting

10 points
Created by:
LionRanger
461

1. Overview

Edit

How do I sort {"10", "1", "2"} into {"1", "2", "10"}

Example:

Problem with default Arrays.sort

2. Alphanumeric Sort Comparator code

Edit

3. Alphanumeric Sort - simple example

Edit

Code example: 


Output:

4. Alphanumeric Sort - complex example

Edit

Code example: 

Output:

5. Alphanumeric Sort case insensitive numerical order example

Edit

Code example:

Output:

Merged questions

Edit
  1. Java - how do I sort String[] in natural order?
  2. Java - sort alphanumeric array of Strings
  3. Java - how to sort alphanumeric array of Strings when Arrays.sort does not work eg 1 10 2 vs 1 2 10?

References

Edit
  1. Natural sort order - wiki
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join