I have a list of versions that I need to sort semantically using Strict Version library in Python. The problem is that there are two strings in the list: 'Unknown' and 'Not A Version' and when I run the code they cause error. Here is the list
ver_list = ['Unknown' 'Not GAP Version' '4.9.3' '4.9.2' '4.9.1' '4.9.0' '4.9' '4.8.9'
'4.8.8' '4.8.7' '4.8.6' '4.8.5' '4.8.4' '4.8.3' '4.8.2' '4.8.10' '4.8.1'
'4.8' '4.7.9' '4.7.8' '4.7.7' '4.7.6' '4.7.5' '4.7.4' '4.7.2' '4.7'
'4.6.9' '4.6.5' '4.6.4' '4.6.3' '4.6.2' '4.6.12' '4.6.1' '4.6' '4.5.7'
'4.5.6' '4.5.5' '4.5.4' '4.5.3' '4.5' '4.49' '4.46' '4.4.9' '4.4.7'
'4.4.6' '4.4.5' '4.4.4' '4.4.3' '4.4.2' '4.4.12' '4.4.11' '4.4.10' '4.4'
'4.3' '4.2' '4.11.0' '4.11' '4.10.2' '4.10.1' '4.10.0' '4.10' '4.1'
'3.4.4' '3.4.3' '3.4' '3.3' '3.2' '3.1' '3.0' '1.1' '1.0']
Here is the code:
ver_list = ver_list.sort(key=StrictVersion)
The error message is ValueError 'Unknown' is not a valid version number...
I also tried to convert the list to pandas dataframe series and used the following code from here How can i sort semantic versions in pandas? but I got the same error message, here is the code to use when versions are your index:
ver = ver.reindex(index=pd.Index(sorted(ver.index, key=StrictVersion)))
I simply need to sort them semantically but the final result to also contain the 'Unknown' and the other string, regardless if they are at the start or at the end. Thank you for the help, much appreciated.