Specific sort

Hi,

I have some patch to apply in order, so I have to sort my list which came from an RPM...

By default my list is sorted like this :
/update/v902002.5_p05.0_00_0
/update/v902002.5_p05.1_08_0
/update/v902002.5_p05.1_08_1
/update/v902002.5_p05.1_08_10
/update/v902002.5_p05.1_08_2
/update/v902002.5_p05.1_08_3
/update/v902002.5_p05.1_08_4
/update/v902002.5_p05.1_08_5
/update/v902002.5_p05.1_08_6
/update/v902002.5_p05.1_08_7
/update/v902002.5_p05.1_08_8
/update/v902002.5_p05.1_08_9

I would love an ansible way to do sort with perhaps a specific option to do like the linux sort with option -V which give me this :

/update/v902002.5_p05.0_00_0
/update/v902002.5_p05.1_08_0
/update/v902002.5_p05.1_08_1
/update/v902002.5_p05.1_08_2
/update/v902002.5_p05.1_08_3
/update/v902002.5_p05.1_08_4
/update/v902002.5_p05.1_08_5
/update/v902002.5_p05.1_08_6
/update/v902002.5_p05.1_08_7
/update/v902002.5_p05.1_08_8
/update/v902002.5_p05.1_08_9
/update/v902002.5_p05.1_08_10

Is there's such an option of sort available ?
If not, is there a way to achieve it ?

Thanks

Regards,

JYL

Currently we have http://jinja.pocoo.org/docs/2.10/templates/#sort,
which does not seem to support a 'numeric' option. A custom filter
would be required.

Elaborating a bit, see https://natsort.readthedocs.io/en/master/index.html.

First "pip install natsort".
Then create filters.py:

from jinja2._compat import string_types
# Custom filter for use with Jinja2
def natsort(arg):
    from natsort import natsorted
    return natsorted(arg)
class FilterModule(object):
    def filters(self):
        return {
                'natsort': natsort
                }

and store it in your filters path (see 'ansible-config dump | grep
DEFAULT_FILTER_PLUGIN_PATH').

Now you can just use "{{ my_version|natsort }}" which gives the order
you're looking for.

Dick