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
Mastering Development

R: How can I subset a list that is a function’s output without declaring the output as a variable?

From the gtools library, take combinations(5,2). This gives the following output: > combinations(5,2) [,1] [,2] [1,] 1 2 [2,] 1 3 [3,] 1 4 [4,] 1 5 [5,] 2 3 [6,] 2 4 [7,] 2 5 [8,] 3 4 [9,] 3 5 [10,] 4 5 Without declaring this output as a variable, I wish to […]

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 […]