<!--- Verify first that your issue is not already reported on GitHub -->
<!--- Also test if the latest release and devel branch are affected too -->
<!--- Complete *all* sections as described, this form is processed automatically -->

##### SUMMARY
<!--- Explain the problem briefly below -->
`unique` filter does not respect the order and gives non-idempotent results

##### ISSUE TYPE
- Bug Report


##### COMPONENT NAME
lib/ansible/plugins/filter/mathstuff.py


##### ANSIBLE VERSION
<!--- Paste verbatim output from "ansible --version" between quotes -->
```paste below
ansible 2.8.5
```

##### STEPS TO REPRODUCE
<!--- Describe exactly how to reproduce the problem, using a minimal test-case -->
I have the following statement in my template 

```jinja2
{% for host in url_list | map('urlsplit', 'hostname') | unique %}
    upstream {{ host }} {
        server {{ host }}:443;
        keepalive 20;
        keepalive_requests 500;
        keepalive_timeout 30s;
    }
{% endfor %}
```

which basically extracts unique host names from some url list and declares upstream server for each. 

##### EXPECTED RESULTS
The order of hosts is at least consistent between runs. 


##### ACTUAL RESULTS
The order of hosts is different for each run. Unexpected handlers are triggered.

if HAS_MIN_MAX:
        return do_max(environment, a, **kwargs)
    else:
        if kwargs:
            raise AnsibleFilterError("Ansible's max filter does not support any keyword arguments. "
                                     "You need Jinja2 2.10 or later that provides their version of the filter.")
        _max = __builtins__.get('max')
        return _max(a)
def logarithm(x, base=math.e):
    try:
        if base == 10:
            return math.log10(x)
        else:
            return math.log(x, base)
    except TypeError as e:
        raise AnsibleFilterTypeError('log() can only be used on numbers: %s' % to_native(e))
def power(x, y):
    try:
        return math.pow(x, y)
    except TypeError as e:
        raise AnsibleFilterTypeError('pow() can only be used on numbers: %s' % to_native(e))
def inversepower(x, base=2):
    try:
        if base == 2:
            return math.sqrt(x)
        else:
            return math.pow(x, 1.0 / float(base))
    except (ValueError, TypeError) as e:
        raise AnsibleFilterTypeError('root() can only be used on numbers: %s' % to_native(e))
def human_readable(size, isbits=False, unit=None):