Hi I have a list of strings as input with leading zeros, and I am wondering how to sort them.
Input (unsorted)
0-2 0-1 1 1-2 1-0 1-1 4-3
Output (sorted)
0-1 0-2 1 1-0 1-1 1-2 4-3
I can remove the "-" and leading zeros, but then 0-1 -> 1 and 1 -> 1 match and cannot be sorted. Another thing that comes to my mind is to remove the zero in these numbers, which do not lead to zero, to put 0 behind, therefore
0-1->1 1->10 10->100
then use java sort and return numbers in starting position, but sorted?
Edit:
- The structure is unlimited in depth, therefore 1-2-3-4-5-6 ...
- I can only have one lead 0
- Only dashes (-) and periods (.) Are allowed decimeters.
java sorting algorithm
Xelian
source share