# Data Mapping cfxdm - dm:sort

**dm:sort:** This cfxdm tag allows the user to sort the data for a given column(s) in ascending or descending order.

**dm: sort syntax:** It supports the below arguments

* **columns (mandatory)**. It accepts one or more column names. If more than one column is specified, use a comma as a separator.
* **order (optional)**. Supported values are '**ascending**' or '**descending**'. When not specified, the default applied sort order is 'ascending'

**dm:sort columns = 'COLUMN\_A,COLUMN\_B,..'**

OR

**dm:sort columns = 'COLUMN\_A,COLUMN\_B,..' & order = 'ascending/descending'**

### Example 1:&#x20;

Sort the selected column. (**ascending** order)

![Empty pipeline](https://2978683539-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LhoMVYxiQlKXh6OxX98%2F-MebGid7vke5zlsypRKs%2F-MebLXv-5Pyukotj10dv%2FScreen%20Shot%202021-07-14%20at%204.28.42%20PM.png?alt=media\&token=0a759fff-1dd0-4846-88bd-5f422a80b8f8)

Step 2: Add the following pipeline code/commands into the above-created pipeline as shown in the below screenshot:

You can copy the below code into your pipeline and execute that in your environment.\
\
\&#xNAN;*`##### This pipeline creates a set of records/dateset details coming from a vCenter`* \
*`##### environment. This dataset includes datastore details, Folder name, guest_hostname,`* \
*`##### guest_ip_address.`*\
\
*`##### This pipeline uses dm sort function to sort the selected columns in ascending`* \
*`##### order and prints the output.`*\
\
*`@dm:empty`* \
*`--> @dm:addrow datastore = 'CFX-QA-Store-NFS-qnap' & Folder = '' & guest_full_name = 'CentOS 4/5/6/7 (64 bit)' & guest_hostname = 'test2.oia.cloudfabrix.com' & guest_ip_address = '10.95.134.17'`* \
\
*`--> @dm:addrow datastore = 'CFX-QA-Store-NFS-qnap' & Folder = 'User VMs' & guest_full_name = 'CentOS 4/5/6/7 (64 bit)' & guest_hostname = 'qa.oia.cloudfabrix.com' & guest_ip_address = '10.95.122.13'`*\
\
*`--> @dm:addrow datastore = 'ENG_ISOs,netapp-qa-nfs' & Folder = 'User VMs,Ravi-Pisupati,TestVMs' & guest_full_name = 'Ubuntu Linux (64 bit)' & guest_hostname = 'ubuntuqa' & guest_ip_address = '10.95.102.172'`*\
\
*`--> @dm:addrow datastore = 'datastore1 (6)' & Folder = 'Ravi-Pisupati' & guest_full_name = 'CentOS 4/5/6/7 (64 bit)' & guest_hostname = 'elkstack' & guest_ip_address = '10.95.121.218'`*\
\
*`--> @dm:addrow datastore = 'datastore1-198' & Folder = '' & guest_full_name = 'Microsoft Windows Server' & guest_hostname = 'spdnode.adwinstack' & guest_ip_address = '10.95.132.4'`* \
\
*`--> @dm:addrow datastore = 'netapp-dev-nfs-01' & Folder = 'User VMs,Ravi-Pisupati,TestVMs' & guest_full_name = 'CentOS 4/5/6/7 (64 bit)' & guest_hostname = 'localhost' & guest_ip_address = '10.95.103.115'`*\
\
*`--> @dm:addrow datastore = 'netapp-dev-nfs-01' & Folder = 'User VMs,Ravi-Pisupati,TestVMs' & guest_full_name = 'CentOS 4/5/6/7 (64 bit)' & guest_hostname = 'localhost' & guest_ip_address = '10.95.103.115'`*\
\
*`--> @dm:addrow datastore = 'netapp-dev-nfs-02' & Folder = 'CFX-Drama,Capri-Demo' & guest_full_name = 'CentOS 4/5/6/7 (64 bit)' & guest_hostname = 'democloudp' & guest_ip_address = '10.95.122.212'`*\
\
*`--> @dm:addrow datastore = 'netapp-dev-nfs-02' & Folder = 'CFX-Drama,Capri-Demo' & guest_full_name = 'CentOS 4/5/6/7 (64 bit)' & guest_hostname = 'ravip-v201-platform' & guest_ip_address = '10.95.122.216'`*\
\
*`--> @dm:addrow datastore = 'netapp-dev-nfs-02' & Folder = 'CFX-Drama,Capri-Demo' & guest_full_name = 'CentOS 4/5/6/7 (64 bit)' & guest_hostname = 'cfxautomatesvc' & guest_ip_address = '10.95.125.116'`*\
\
*`--> @dm:sort columns = 'datastore'`*<br>

![Pipeline code added to empty pipeline created](https://2978683539-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LhoMVYxiQlKXh6OxX98%2F-MebSA13DA-3E5K-OHIr%2F-MebUCyr6ze9LkwKRPbI%2FScreen%20Shot%202021-07-14%20at%205.06.48%20PM.png?alt=media\&token=e3831a7e-218d-4562-a61b-923a73db1aad)

Step 3: Click verify button to make sure syntax and pipeline code is correct (as shown below)

![Pipeline code is verified using 'Verify' button as shown above.](https://2978683539-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LhoMVYxiQlKXh6OxX98%2F-MebUOoE1XI5YLm3WU1U%2F-MebUfPAvw4_uYK2MFbC%2FScreen%20Shot%202021-07-14%20at%205.08.51%20PM.png?alt=media\&token=709c3d7b-a546-4ce7-ace7-5079d879c720)

Step 4: Click execute button and execute the pipeline. RDA will execute the pipeline without any errors (as shown below)

![Successful execution of pipeline without any errors](https://2978683539-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LhoMVYxiQlKXh6OxX98%2F-MebUofqhDwxqlW8-cfg%2F-MebV9EnIRZf9efOtc0x%2FScreen%20Shot%202021-07-14%20at%205.11.00%20PM.png?alt=media\&token=9e1f9049-f5ff-491f-84cb-3d1259f1cd73)

Step 5: RDA uses the dm sort function to perform the default sort of the column values (text-based) \
&#x20;and prints the output for each dataset (or row) as shown in the following screenshot.

![Successful execution of pipeline using dm function 'dm:sort' and prints output ](https://2978683539-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LhoMVYxiQlKXh6OxX98%2F-MebVboZI5YDILUFyW6x%2F-MebW-AclbuKj23cz5dR%2FScreen%20Shot%202021-07-14%20at%205.14.40%20PM.png?alt=media\&token=19fb5535-cd5b-4e70-a977-cb0918c0280f)

### Example 2:&#x20;

Sort the selected column. (**descending** order)

![Empty pipeline](https://2978683539-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LhoMVYxiQlKXh6OxX98%2F-MefcJHOqJXDjky_wDaI%2F-MefchvD_5sZim8W1iBl%2FScreen%20Shot%202021-07-15%20at%2012.26.44%20PM.png?alt=media\&token=1e8338f4-08ae-4536-bf93-5070a87de949)

Step 2: Add the following pipeline code/commands into the above-created pipeline as shown in the below screenshot:

You can copy the below code into your pipeline and execute that in your environment.\
\
\&#xNAN;*`##### This pipeline creates a set of records/dateset details coming from a vCenter`* \
*`##### environment. This dataset includes datastore details, Folder name, guest_hostname,`* \
*`##### guest_ip_address.`*\
\
*`##### This pipeline uses dm sort function to sort the selected columns in ascending`* \
*`##### order and prints the output.`*\
\
*`@dm:empty`* \
*`--> @dm:addrow datastore = 'CFX-QA-Store-NFS-qnap' & Folder = '' & guest_full_name = 'CentOS 4/5/6/7 (64 bit)' & guest_hostname = 'test2.oia.cloudfabrix.com' & guest_ip_address = '10.95.134.17'`* \
\
*`--> @dm:addrow datastore = 'CFX-QA-Store-NFS-qnap' & Folder = 'User VMs' & guest_full_name = 'CentOS 4/5/6/7 (64 bit)' & guest_hostname = 'qa.oia.cloudfabrix.com' & guest_ip_address = '10.95.122.13'`*\
\
*`--> @dm:addrow datastore = 'ENG_ISOs,netapp-qa-nfs' & Folder = 'User VMs,Ravi-Pisupati,TestVMs' & guest_full_name = 'Ubuntu Linux (64 bit)' & guest_hostname = 'ubuntuqa' & guest_ip_address = '10.95.102.172'`*\
\
*`--> @dm:addrow datastore = 'datastore1 (6)' & Folder = 'Ravi-Pisupati' & guest_full_name = 'CentOS 4/5/6/7 (64 bit)' & guest_hostname = 'elkstack' & guest_ip_address = '10.95.121.218'`*\
\
*`--> @dm:addrow datastore = 'datastore1-198' & Folder = '' & guest_full_name = 'Microsoft Windows Server' & guest_hostname = 'spdnode.adwinstack' & guest_ip_address = '10.95.132.4'`* \
\
*`--> @dm:addrow datastore = 'netapp-dev-nfs-01' & Folder = 'User VMs,Ravi-Pisupati,TestVMs' & guest_full_name = 'CentOS 4/5/6/7 (64 bit)' & guest_hostname = 'localhost' & guest_ip_address = '10.95.103.115'`*\
\
*`--> @dm:addrow datastore = 'netapp-dev-nfs-01' & Folder = 'User VMs,Ravi-Pisupati,TestVMs' & guest_full_name = 'CentOS 4/5/6/7 (64 bit)' & guest_hostname = 'localhost' & guest_ip_address = '10.95.103.115'`*\
\
*`--> @dm:addrow datastore = 'netapp-dev-nfs-02' & Folder = 'CFX-Drama,Capri-Demo' & guest_full_name = 'CentOS 4/5/6/7 (64 bit)' & guest_hostname = 'democloudp' & guest_ip_address = '10.95.122.212'`*\
\
*`--> @dm:addrow datastore = 'netapp-dev-nfs-02' & Folder = 'CFX-Drama,Capri-Demo' & guest_full_name = 'CentOS 4/5/6/7 (64 bit)' & guest_hostname = 'ravip-v201-platform' & guest_ip_address = '10.95.122.216'`*\
\
*`--> @dm:addrow datastore = 'netapp-dev-nfs-02' & Folder = 'CFX-Drama,Capri-Demo' & guest_full_name = 'CentOS 4/5/6/7 (64 bit)' & guest_hostname = 'cfxautomatesvc' & guest_ip_address = '10.95.125.116'`*\
\
*`--> @dm:sort columns = 'datastore' & order = 'descending'`*<br>

![Pipeline code added to empty pipeline created (with descending option)](https://2978683539-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LhoMVYxiQlKXh6OxX98%2F-Mefcs7ZKEJRZUlGNG0P%2F-MefdVeCp_z-m3DaAi9p%2FScreen%20Shot%202021-07-15%20at%2012.30.18%20PM.png?alt=media\&token=99d614e7-c1dc-4836-b104-9fd7078c0ad1)

Step 3: Click verify button to make sure syntax and pipeline code is correct (as shown below)

![Pipeline code is verified using 'Verify' button as shown above.](https://2978683539-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LhoMVYxiQlKXh6OxX98%2F-Mefdh6odkzkTmf6STlS%2F-Mefe1rtSpxBfeoDq9yH%2FScreen%20Shot%202021-07-15%20at%2012.32.35%20PM.png?alt=media\&token=6848d1e7-7923-4449-999b-63a8f64523a0)

Step 4: Click execute button and execute the pipeline. RDA will execute the pipeline without any errors (as shown below)

![Successful execution of pipeline without any errors](https://2978683539-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LhoMVYxiQlKXh6OxX98%2F-MefeJ8Oubw0FAqPR-II%2F-MefexH0wu4jFd3UTFdv%2FScreen%20Shot%202021-07-15%20at%2012.36.37%20PM.png?alt=media\&token=911ee790-e733-4864-8b3d-e83d5da00d87)

Step 5: RDA uses the dm sort function to perform the default sort of the column values (text-based) \
&#x20;in descending order and prints the output for each dataset (or row) as shown in the following screenshot.

![Successful execution of pipeline using dm function 'dm:sort' and prints output ](https://2978683539-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LhoMVYxiQlKXh6OxX98%2F-MeffD_F_7PEF0FL3GID%2F-MefgDKpRKB8iaF1oGhO%2FScreen%20Shot%202021-07-15%20at%2012.42.09%20PM.png?alt=media\&token=73b2f154-a78c-4dc3-a558-cd23d9bb599d)

### Example 3:&#x20;

Sort the selected multiple columns. (**descending** order)

![Empty pipeline ](https://2978683539-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LhoMVYxiQlKXh6OxX98%2F-MefgZybj1Q5-k6EePj8%2F-MefgyvBwe4eILJhshyo%2FScreen%20Shot%202021-07-15%20at%2012.45.27%20PM.png?alt=media\&token=1690ab8c-680f-4e40-99fb-57f679e43298)

Step 2: Add the following pipeline code/commands into the above-created pipeline as shown in the below screenshot:

You can copy the below code into your pipeline and execute that in your environment.\
\
\&#xNAN;*`##### This pipeline creates a set of records/dateset details coming from a vCenter`* \
*`##### environment. This dataset includes datastore details, Folder name, guest_hostname,`* \
*`##### guest_ip_address.`*\
\
*`##### This pipeline uses dm sort function to sort the selected columns in ascending`* \
*`##### order and prints the output.`*\
\
*`@dm:empty`* \
*`--> @dm:addrow datastore = 'CFX-QA-Store-NFS-qnap' & Folder = '' & guest_full_name = 'CentOS 4/5/6/7 (64 bit)' & guest_hostname = 'test2.oia.cloudfabrix.com' & guest_ip_address = '10.95.134.17'`* \
\
*`--> @dm:addrow datastore = 'CFX-QA-Store-NFS-qnap' & Folder = 'User VMs' & guest_full_name = 'CentOS 4/5/6/7 (64 bit)' & guest_hostname = 'qa.oia.cloudfabrix.com' & guest_ip_address = '10.95.122.13'`*\
\
*`--> @dm:addrow datastore = 'ENG_ISOs,netapp-qa-nfs' & Folder = 'User VMs,Ravi-Pisupati,TestVMs' & guest_full_name = 'Ubuntu Linux (64 bit)' & guest_hostname = 'ubuntuqa' & guest_ip_address = '10.95.102.172'`*\
\
*`--> @dm:addrow datastore = 'datastore1 (6)' & Folder = 'Ravi-Pisupati' & guest_full_name = 'CentOS 4/5/6/7 (64 bit)' & guest_hostname = 'elkstack' & guest_ip_address = '10.95.121.218'`*\
\
*`--> @dm:addrow datastore = 'datastore1-198' & Folder = '' & guest_full_name = 'Microsoft Windows Server' & guest_hostname = 'spdnode.adwinstack' & guest_ip_address = '10.95.132.4'`* \
\
*`--> @dm:addrow datastore = 'netapp-dev-nfs-01' & Folder = 'User VMs,Ravi-Pisupati,TestVMs' & guest_full_name = 'CentOS 4/5/6/7 (64 bit)' & guest_hostname = 'localhost' & guest_ip_address = '10.95.103.115'`*\
\
*`--> @dm:addrow datastore = 'netapp-dev-nfs-01' & Folder = 'User VMs,Ravi-Pisupati,TestVMs' & guest_full_name = 'CentOS 4/5/6/7 (64 bit)' & guest_hostname = 'localhost' & guest_ip_address = '10.95.103.115'`*\
\
*`--> @dm:addrow datastore = 'netapp-dev-nfs-02' & Folder = 'CFX-Drama,Capri-Demo' & guest_full_name = 'CentOS 4/5/6/7 (64 bit)' & guest_hostname = 'democloudp' & guest_ip_address = '10.95.122.212'`*\
\
*`--> @dm:addrow datastore = 'netapp-dev-nfs-02' & Folder = 'CFX-Drama,Capri-Demo' & guest_full_name = 'CentOS 4/5/6/7 (64 bit)' & guest_hostname = 'ravip-v201-platform' & guest_ip_address = '10.95.122.216'`*\
\
*`--> @dm:addrow datastore = 'netapp-dev-nfs-02' & Folder = 'CFX-Drama,Capri-Demo' & guest_full_name = 'CentOS 4/5/6/7 (64 bit)' & guest_hostname = 'cfxautomatesvc' & guest_ip_address = '10.95.125.116'`*\
\
*`--> @dm:sort columns = 'datastore,guest_full_name' & order = 'descending'`*

![Pipeline code added to empty pipeline (with multiple columns in sort function and descending order option)](https://2978683539-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LhoMVYxiQlKXh6OxX98%2F-Mefhcm3uwh8uSwzafob%2F-MefhcymAiPNfcYVXEHP%2FScreen%20Shot%202021-07-15%20at%2012.48.16%20PM.png?alt=media\&token=de2cad5b-b553-4d32-a44f-b3577f714a1a)

Step 3: Click verify button to make sure syntax and pipeline code is correct (as shown below)

![Pipeline code is verified using 'Verify' button as shown above.](https://2978683539-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LhoMVYxiQlKXh6OxX98%2F-Mefi30XPYjLSkeE3zTB%2F-MefiKyiPkqK-TTgjyAf%2FScreen%20Shot%202021-07-15%20at%2012.51.19%20PM.png?alt=media\&token=c25e5d75-f80e-4289-9717-068ffa6d45f1)

Step 4: Click execute button and execute the pipeline. RDA will execute the pipeline without any errors (as shown below)

![Successful execution of pipeline without any errors](https://2978683539-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LhoMVYxiQlKXh6OxX98%2F-MefiUfsSsRNWEBFQc2D%2F-MefjOZZRV6hljZOtc6a%2FScreen%20Shot%202021-07-15%20at%2012.56.01%20PM.png?alt=media\&token=4b428c70-e761-412a-a85f-c75d06f18ab5)

Step 5: RDA uses the dm sort function to perform the default sort of the multiple column values (text-based) \
&#x20;in descending order and prints the output for each dataset (or row) as shown in the following screenshot.

![Successful execution of pipeline using dm function 'dm:sort' and prints output ](https://2978683539-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LhoMVYxiQlKXh6OxX98%2F-MefkH9vwRn9KCHMPUus%2F-MefkIpFL-i9a4XN6KWD%2FScreen%20Shot%202021-07-15%20at%2012.59.39%20PM.png?alt=media\&token=ae21e001-d514-4739-b562-59c720be7d30)
