You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An alphanumeric comparator in Java, for comparing strings in a human readable format. It uses a combination numeric and alphabetic comparisons to compare two strings. This class uses standard Java classes and is independent of any 3rd party libraries.
4
+
An alphanumeric comparator in Java, for comparing strings in a human readable format. It uses a combination of numeric and alphabetic comparisons to compare two strings. This class uses standard Java classes and is independent of any 3rd party libraries.
5
5
6
-
Additionally this comparator uses ```java.text.Collator``` class to correctly sort strings containing special Unicode characters like Umlauts or other similar letters of alphabet in different languages, such as: **å**, **è**, **ü**, **ö**, **ø**, or **ý**.
6
+
Additionally this comparator uses ```java.text.Collator``` class to correctly sort strings containing special characters like Umlauts or similar alphabet letters in different languages, such as: **å**, **è**, **ü**, **ö**, **ø**, or **ý**.
7
7
8
8
#### Example #1
9
9
For given list of strings:
10
10
- file-01.doc
11
11
- file-2.doc
12
12
- file-03.doc
13
13
14
-
The regular lexicographical sorts, e.g. ```java.util.Collections.sort()```, sorts the above list in following order:
14
+
A regular lexicographical sort, e.g. ```java.util.Collections.sort()```, sorts the above list in the following order:
15
15
16
16
***[file-01.doc, file-03.doc, file-2.doc]***
17
17
18
-
However using ```AlphaNumericComparator```, the list will be sorter in more meaningful and readable way:
18
+
However using ```AlphaNumericComparator```, the list will be sorted in a more meaningful and readable way:
19
19
20
20
***[file-01.doc, file-2.doc, file-03.doc]***
21
21
@@ -29,7 +29,7 @@ For the following list of characters/strings:
29
29
* è
30
30
* g
31
31
32
-
The regular lexicographical sorts, e.g. ```java.util.Collections.sort()```, sorts the above list in following order:
32
+
A regular lexicographical sort, e.g. ```java.util.Collections.sort()```, sorts the above list in the following order:
33
33
34
34
**[b, e, f, g, k, è, ě]**
35
35
@@ -39,7 +39,7 @@ Using ```AlphaNumericComparator```, the list is correctly sorted as below:
39
39
40
40
#### How To
41
41
42
-
Just pass the comparator as a parameter when sorting a list:
42
+
Simply pass the comparator as a parameter when sorting a list:
0 commit comments