I have a postgres database storing all versions of different pip packages.
The format looks something like X.X.X (e.g. 01.9.1 or 14.12.03) and is a string. The number X can be something between 1 and a finite number n.
I would now like to read them in my Django app and order the versions to get the newest version by package.
My first idea was something like:
Version.objects.filter(package='example').order_by('version').last()
.
The problem is, this returns '0.9.1' instead of '0.21.1' if we have these two versions as an example.
Is there an easy way to get the ordering correct?
This would mean:
1.) Order by highest number before the first dot
2.) Order by highest number in the middle section
3.) Order by highest number after the second dot