Categories
Mastering Development

Java program to sort a versioning string in an ascending order

I have a list containing version strings, such as things: versions_list = ["1.1.2", "1.0.0", "1.3.3", "1.0.12", "1.0.2"] I would like to sort it, so the result would be something like this: versions_list = ["1.0.0", "1.0.2", "1.0.12", "1.1.2", "1.3.3"] How to do this in Java.

Categories
Development

implement sorting for list of dictionary having versions as key in python

I’m trying to use StrictVersion on the code below: from distutils.version import StrictVersion from operator import itemgetter v = [{‘ver’: ‘1.1.12’},{‘ver’: ‘1.0.0’},{‘ver’: ‘1.3.3’},{‘ver’: ‘1.0.12’},{‘ver’: ‘1.0.2’}] v.sort(key=itemgetter(“ver”),reverse=True) This is sorting based on version with below code but it’s not sorting properly in above code. versions = [“1.1.2”, “1.0.0”, “1.3.3”, “1.0.12”, “1.0.2”] versions.sort(key=StrictVersion,reverse=True) How to use key=StrictVersion […]