<!--- 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_min(self):
        assert ms.min(env, (1, 2)) == 1
        assert ms.min(env, (2, 1)) == 1
        assert ms.min(env, ('p', 'a', 'w', 'b', 'p')) == 'a'
        assert ms.min(env, ({'key': 'a'}, {'key': 'b'}, {'key': 'c'}), attribute='key') == {'key': 'a'}
        assert ms.min(env, ({'key': 1}, {'key': 2}, {'key': 3}), attribute='key') == {'key': 1}
        assert ms.min(env, ('a', 'A', 'b', 'B'), case_sensitive=True) == 'A'
class TestMax:
    def test_max(self):
        assert ms.max(env, (1, 2)) == 2
        assert ms.max(env, (2, 1)) == 2
        assert ms.max(env, ('p', 'a', 'w', 'b', 'p')) == 'w'
        assert ms.max(env, ({'key': 'a'}, {'key': 'b'}, {'key': 'c'}), attribute='key') == {'key': 'c'}
        assert ms.max(env, ({'key': 1}, {'key': 2}, {'key': 3}), attribute='key') == {'key': 3}
        assert ms.max(env, ('a', 'A', 'b', 'B'), case_sensitive=True) == 'b'
class TestLogarithm:
    def test_log_non_number(self):
        
        with pytest.raises(AnsibleFilterTypeError, match='log\\(\\) can only be used on numbers: (a float is required|must be real number, not str)'):
            ms.logarithm('a')
        with pytest.raises(AnsibleFilterTypeError, match='log\\(\\) can only be used on numbers: (a float is required|must be real number, not str)'):
            ms.logarithm(10, base='a')
    def test_log_ten(self):
        assert ms.logarithm(10, 10) == 1.0
        assert ms.logarithm(69, 10) * 1000 // 1 == 1838
    def test_log_natural(self):
        assert ms.logarithm(69) * 1000 // 1 == 4234
    def test_log_two(self):
        assert ms.logarithm(69, 2) * 1000 // 1 == 6108
class TestPower: