My input string array is like below:
String[] arr = {"2T1BURHE1JCO24154C", "2TABURHE1JC024154C", "JTDKARFP5H3055472C", "2T2BURHE1JCO24154C", "JTDKARFP1H3056246C"};
The output array should be as below:
{"JTDKARFP1H3056246C",
"JTDKARFP5H3055472C",
"2TABURHE1JC024154C",
"2T1BURHE1JCO24154C",
"2T2BURHE1JCO24154C"}
Here the priority is given in the below pattern:
[ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789]
When I use the Arrays.sort(arr) in Java it sorts the array in dictionary pattern and gives the below output:
[2T1BURHE1JCO24154C, 2T2BURHE1JCO24154C, 2TABURHE1JC024154C, JTDKARFP1H3056246C, JTDKARFP5H3055472C]
How could I achieve this in Java.
Thanks.
Aucun commentaire:
Enregistrer un commentaire