<!--- 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.

def test_power_non_number(self):
        
        with pytest.raises(AnsibleFilterTypeError, match='pow\\(\\) can only be used on numbers: (a float is required|must be real number, not str)'):
            ms.power('a', 10)
        with pytest.raises(AnsibleFilterTypeError, match='pow\\(\\) can only be used on numbers: (a float is required|must be real number, not str)'):
            ms.power(10, 'a')
    def test_power_squared(self):
        assert ms.power(10, 2) == 100
    def test_power_cubed(self):
        assert ms.power(10, 3) == 1000
class TestInversePower:
    def test_root_non_number(self):
        
        with pytest.raises(AnsibleFilterTypeError, match="root\\(\\) can only be used on numbers:"
                           " (invalid literal for float\\(\\): a"
                           "|could not convert string to float: a"
                           "|could not convert string to float: 'a')"):
            ms.inversepower(10, 'a')
        with pytest.raises(AnsibleFilterTypeError, match="root\\(\\) can only be used on numbers: (a float is required|must be real number, not str)"):
            ms.inversepower('a', 10)
    def test_square_root(self):
        assert ms.inversepower(100) == 10
        assert ms.inversepower(100, 2) == 10
    def test_cube_root(self):
        assert ms.inversepower(27, 3) == 3
class TestRekeyOnMember():