How to use version compare test in selectattr?

Hi

I'm trying to use version compare in selectattr but get error message "Version comparison failed: '<' not supported between instances of 'int' and 'str'
This is the playboot I'm using

- hosts: localhost
   gather_facts: no
   vars:
     my:
       - vers: "5.43"
       - vers: "4.34"
   tasks:
     - debug:
         msg: |
           {{ my.0.vers is version("5", "<") }}
           {{ my.1.vers is version("5", "<") }}
     - debug:
         msg:
           {{ my | selectattr('vers', 'version', '"5", "<"' }}

The output I get is:

ansible-playboot test.yml
PLAY [localhost] *****

TASK [debug] *****
OK: [localhost] => {}

MSG:

False
True

TASK [debug] *****
fatal: [localhost]: FAILED! => {}

MSG:

Version comparison failed: '<' not supported between instances of 'int' and 'str'

Anyone have any idea how to do this?

That last expression is too quoty (and missing a close parenthesis). Try

{{ my | selectattr(‘vers’, ‘version’, ‘5’, ‘<’) }}

The missing parenthesis is just a typo, but removing the quotes work, thanks Todd.

This is the correct syntax

    - debug:
        msg: |
          {{ my | selectattr('vers', 'version', '5', '<') }}