+ {{#sorting}}
+ {{#hassortablecolumns}}
+
+ {{/hassortablecolumns}}
+
+ {{^hassortablecolumns}}
+ {{< core_reportbuilder/local/settings/empty_message }}
+ {{$nothingtoshow}}{{#str}} nosortablecolumns, core_reportbuilder {{/str}} {{/nothingtoshow}}
+ {{/ core_reportbuilder/local/settings/empty_message }}
+ {{/hassortablecolumns}}
+ {{/sorting}}
+
\ No newline at end of file
diff --git a/reportbuilder/tests/behat/columnsortingeditor.feature b/reportbuilder/tests/behat/columnsortingeditor.feature
new file mode 100644
index 00000000000..95cf40fe319
--- /dev/null
+++ b/reportbuilder/tests/behat/columnsortingeditor.feature
@@ -0,0 +1,72 @@
+@core_reportbuilder @javascript
+Feature: Manage custom report columns sorting
+ In order to manage the sorting for columns of custom reports
+ As an admin
+ I need to be able to enable/disable, change sort direction and reorder sorting for columns
+
+ Background:
+ Given the following "core_reportbuilder > Reports" exist:
+ | name | source | default |
+ | My report | core_user\reportbuilder\datasource\users | 0 |
+ And the following "core_reportbuilder > Columns" exist:
+ | report | uniqueidentifier |
+ | My report | user:username |
+ | My report | user:lastname |
+ | My report | user:firstname |
+ And the following "users" exist:
+ | username | firstname | lastname | email |
+ | user01 | Alice | Zebra | user01@example.com |
+ | user02 | Zoe | Aardvark | user02@example.com |
+ And I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
+
+ Scenario: Toggle column sorting in report
+ Given I click on "Show/hide settings sidebar" "button"
+ And I change window size to "large"
+ And I click on "Show/hide 'Sorting'" "button"
+ # This will be the fallback sort after toggling lastname sorting.
+ And I click on "Enable sorting for column 'First name'" "checkbox"
+ When I click on "Enable sorting for column 'Surname'" "checkbox"
+ Then I should see "Updated sorting for column 'Surname'"
+ And "user02" "table_row" should appear before "user01" "table_row"
+ And I click on "Disable sorting for column 'Surname'" "checkbox"
+ And I should see "Updated sorting for column 'Surname'"
+ And "user01" "table_row" should appear before "user02" "table_row"
+
+ Scenario: Change column sort direction in report
+ Given I click on "Show/hide settings sidebar" "button"
+ And I change window size to "large"
+ And I click on "Show/hide 'Sorting'" "button"
+ When I click on "Enable sorting for column 'Surname'" "checkbox"
+ And I click on "Sort column 'Surname' descending" "button"
+ Then I should see "Updated sorting for column 'Surname'"
+ And "user01" "table_row" should appear before "user02" "table_row"
+ And I click on "Sort column 'Surname' ascending" "button"
+ And I should see "Updated sorting for column 'Surname'"
+ And "user02" "table_row" should appear before "user01" "table_row"
+
+ Scenario: Change column sort order in report
+ Given I click on "Show/hide settings sidebar" "button"
+ And I change window size to "large"
+ And I click on "Show/hide 'Sorting'" "button"
+ When I click on "Enable sorting for column 'Surname'" "checkbox"
+ And I click on "Enable sorting for column 'First name'" "checkbox"
+ And I click on "Move sorting for column 'First name'" "button"
+ And I click on "To the top of the list" "link" in the "Move sorting for column 'First name'" "dialogue"
+ Then I should see "Updated sorting for column 'First name'"
+ And "First name" "text" should appear before "Surname" "text" in the "#settingssorting" "css_element"
+ And "user01" "table_row" should appear before "user02" "table_row"
+
+ Scenario: Sortable columns are updated when column is added to report
+ Given I click on "Show/hide settings sidebar" "button"
+ And I change window size to "large"
+ And I click on "Show/hide 'Sorting'" "button"
+ When I click on "Add column 'Full name'" "link"
+ Then I should see "Full name" in the "#settingssorting" "css_element"
+
+ Scenario: Sortable columns are updated when column is deleted from report
+ Given I click on "Show/hide settings sidebar" "button"
+ And I change window size to "large"
+ And I click on "Show/hide 'Sorting'" "button"
+ When I click on "Delete column 'Username'" "link"
+ And I click on "Delete" "button" in the "Delete column 'Username'" "dialogue"
+ Then I should not see "Username" in the "#settingssorting" "css_element"
diff --git a/reportbuilder/tests/external/columns/sort/reorder_test.php b/reportbuilder/tests/external/columns/sort/reorder_test.php
new file mode 100644
index 00000000000..10b4b7c763e
--- /dev/null
+++ b/reportbuilder/tests/external/columns/sort/reorder_test.php
@@ -0,0 +1,114 @@
+.
+
+declare(strict_types=1);
+
+namespace core_reportbuilder\external\columns\sort;
+
+use core_reportbuilder_generator;
+use external_api;
+use externallib_advanced_testcase;
+use core_reportbuilder\report_access_exception;
+use core_reportbuilder\local\models\column;
+use core_user\reportbuilder\datasource\users;
+
+defined('MOODLE_INTERNAL') || die();
+
+global $CFG;
+require_once("{$CFG->dirroot}/webservice/tests/helpers.php");
+
+/**
+ * Unit tests of external class for re-ordering report column sorting
+ *
+ * @package core_reportbuilder
+ * @covers \core_reportbuilder\external\columns\sort\reorder
+ * @copyright 2021 Paul Holden