How to sort the Version(i.e) '1.4.7','5.19.0','5.18.0','5.14.1','5.8.1','5.8.2','5.20.1','5.20.0'
something like this. Initially tried with splitting by DOT and then comparing the First value in a list and second and so on, which worked totally fine or using bubble sort.
But then Requirement changed and sorting Input is AlphaNumneric
{'1.4.7','5.14.2', '8.2.alpha', '9.beta', 'other'}
Which I changed to an integer by using string CharAt. But it fails at some test cases as 5.14.1 value is around 100+ and 5.20.1 value is less than 100 and it's wrong.
b = b + integer.valueOf(val.charAt(k));
Saw Apex CompareTo Not sure if it will work in my case or No idea How it works.
Will it works for my requirement
and please provide the sample code.