> For the complete documentation index, see [llms.txt](https://docs.cloudfabrix.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cloudfabrix.io/rda/rda-userguide/rda-aiops-studio/examples-jupyter/data-mapping-cfxdm-dm-sort.md).

# 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](/files/-MebLXv-5Pyukotj10dv)

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](/files/-MebUCyr6ze9LkwKRPbI)

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.](/files/-MebUfPAvw4_uYK2MFbC)

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](/files/-MebV9EnIRZf9efOtc0x)

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 ](/files/-MebW-AclbuKj23cz5dR)

### Example 2:&#x20;

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

![Empty pipeline](/files/-MefchvD_5sZim8W1iBl)

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)](/files/-MefdVeCp_z-m3DaAi9p)

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.](/files/-Mefe1rtSpxBfeoDq9yH)

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](/files/-MefexH0wu4jFd3UTFdv)

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 ](/files/-MefgDKpRKB8iaF1oGhO)

### Example 3:&#x20;

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

![Empty pipeline ](/files/-MefgyvBwe4eILJhshyo)

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)](/files/-MefhcymAiPNfcYVXEHP)

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.](/files/-MefiKyiPkqK-TTgjyAf)

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](/files/-MefjOZZRV6hljZOtc6a)

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 ](/files/-MefkIpFL-i9a4XN6KWD)
