Sorting by Multiple Columns

Introduction

In this tutorial, you will learn how to sort a List by multiple columns in Joget. Although Joget does not natively support multi-column sorting, you can achieve this by using a custom SQL query. 

How does it work?

This example demonstrates sorting by three columns: Country, First Name, and Last Name.

Form design

Create a form to input the data. This will be the source of the List that you want to sort.

List design

Design the list where the sorted data will be displayed. Joget does not support multi-column sorting directly, so you need to use the Database SQL query to achieve this.

SQL Query for multi-column sorting

Use the following SQL query to sort the List by Country, then First Name, and then Last Name. This query ensures that your data is ordered correctly according to your specified columns.

SELECT c_country
  , c_first_name
  , c_last_name
FROM
    (
        SELECT c_country
          , c_first_name
          , c_last_name
        FROM
            app_fd_details
        ORDER BY
            c_country asc
          , c_first_name asc
          , c_last_name asc
        LIMIT 18446744073709551615
    )
    alias

Expected outcome

Applying the above SQL query, the List will be sorted first by Country, then by First Name, and finally by Last Name. The data will be displayed in the specified order on the list.

Download sample app

Download the demo app for Sorting by Multiple Columns:
Created by Julieth Last modified by Aadrian on Dec 13, 2024