Repository: ansible-collections/community.vmware

Issue:
community.vmware.vmware_dvs_host adding pNIC inverted (starting at Uplink 4)
<!--- 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
When using the community.vmware.vmware_dvs_host to create and add uplinks to Distributed vSwitch (4 uplinks) when PNICs are added they are added at Uplink 4 for VMNIC0, Uplink 3 for VMNIC1, .... 

##### ISSUE TYPE
- Bug Report

##### COMPONENT NAME
community.vmware.vmware_dvs_host

##### ANSIBLE VERSION
<!--- Paste verbatim output from "ansible --version" between quotes -->
```
ansible 2.10.7
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.6/site-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.6.8 (default, Aug 13 2020, 07:46:32) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]

```

##### COLLECTION VERSION
<!--- Paste verbatim output from "ansible-galaxy collection list <namespace>.<collection>"  between the quotes
for example: ansible-galaxy collection list community.general
-->
```
# /root/.ansible/collections/ansible_collections
Collection            Version
--------------------- -------
ansible.netcommon     2.3.0
ansible.posix         1.2.0
ansible.utils         2.3.1
community.docker      1.3.0
community.general     1.3.1
community.kubernetes  1.1.1
community.vmware      1.15.0
dellemc.openmanage    2.1.4
f5networks.f5_modules 1.11.0
google.cloud          1.0.1

```

##### CONFIGURATION
<!--- Paste verbatim output from "ansible-config dump --only-changed" between quotes -->
```
DEFAULT_HOST_LIST(/etc/ansible/ansible.cfg) = ['/etc/ansible/hosts']
DEFAULT_ROLES_PATH(/etc/ansible/ansible.cfg) = ['/etc/ansible/roles']
HOST_KEY_CHECKING(/etc/ansible/ansible.cfg) = False
RETRY_FILES_ENABLED(/etc/ansible/ansible.cfg) = False
```

##### OS / ENVIRONMENT
<!--- Provide all relevant information below, e.g. target OS versions, network device firmware, etc. -->
cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.9 (Maipo)

##### STEPS TO REPRODUCE
<!--- Describe exactly how to reproduce the problem, using a minimal test-case -->

<!--- Paste example playbooks or commands between quotes below -->
```
- name: Add Host to dVS  "{{outside.esxi_hostname}}"
  community.vmware.vmware_dvs_host:
    hostname: "{{ vcenter_hostname }}"
    username: "{{ vcenter_username }}"
    password: "{{ vcenter_password }}"
    esxi_hostname: "{{ outside.esxi_hostname }}"
    validate_certs: false
    switch_name: "{{ vcenter_dvs_sw }}"
    vmnics:
        - "{{migrated_adapter}}"
    state: present

```

<!--- HINT: You can paste gist.github.com links for larger files -->

##### EXPECTED RESULTS
<!--- Describe what you expected to happen when running the steps above -->

When adding pNICs to DVS i would expect it to start with Uplink-1 and move downward not inverted.

##### ACTUAL RESULTS
<!--- Describe what actually happened. If possible run with extra verbosity (-vvvv) -->

Code runs correctly PNIC (VMNIC0 links to Uplink-4, VMNIC1 links to Uplink-3....




Discussion:
Files identified in the description:
None

If these files are inaccurate, please update the `component name` section of the description or use the `!component` bot command.

[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: components_banner --->

Resolving patch:
diff --git a/plugins/modules/vmware_dvs_host.py b/plugins/modules/vmware_dvs_host.py
--- a/plugins/modules/vmware_dvs_host.py
+++ b/plugins/modules/vmware_dvs_host.py
@@ -300,7 +300,7 @@ def set_desired_state(self):
                         switch_uplink_ports[name].append(port.key)
                         lag_uplinks.append(port.key)
 
-        for port in ports:
+        for port in sorted(ports, key=lambda port: port.config.name):
             if port.key in self.uplink_portgroup.portKeys and port.key not in lag_uplinks:
                 switch_uplink_ports['non_lag'].append(port.key)
 


Test patch: