I'm trying to get the highest version number of a software product from its website with Ansible. I can get a list with the version numbers without problem like this:
set_fact:
  app_version: "{{ lookup('url', 'https://example.com/product/versions.json') 
    | regex_findall('"version":"(.+?)"', '\\1') 
    | unique }}"
The problem is to get the highest version number, because the sort() filter compares plain strings, and not like a human would.
Example:
---
- hosts: localhost
  gather_facts: no
  vars:
    list: [ '6.13.15', '6.5.8', '6.14.5' ]
  tasks:
  - name: "sort version numbers"
    set_fact:
      app_version: "{{ list | sort }}"
  - name: debug
    debug:
      var: app_version
This results in the output:
ok: [localhost] => {
    "app_version": [
        "6.13.15",
        "6.14.5",
        "6.5.8"
    ]
}
Which is obviously wrong, 6.5 should be before 6.13, not after. Is there any way to sort a list with Jinja2 filters like a human would, or at least to sort version numbers properly?