5 min readUpdated Mar 2, 2026

Sort Logic Documentation

Overview

The Sort Logic in the Vantage platform is designed to enable users to sort datasets based on specified fields in either ascending or descending order. This functionality is vital for data analysis, allowing users to organize their data efficiently before processing, visualizing, or drawing insights from it.

Purpose

The primary purpose of the Sort Logic is to rearrange elements in an array based on a specified criterion. It provides flexibility through various sorting methods, including standard sorting, custom orders, and user-defined comparators, making it versatile for multiple data scenarios.

Settings

1. Field

2. Direction

3. CustomOrder

4. Comparator

How It Works

Upon invoking the createSortNode function, the Sort Logic performs the following operations:

  1. Input Validation: First, it checks if the input data is an array. If not, it returns an empty array.
  2. Custom Comparator: If a custom comparator function is provided, it uses that function to sort the data.
  3. Custom Order: If a custom order array is provided, it maps the defined order to the data based on the specified field.
  4. Standard Sorting: If no custom sort options are defined, it performs a standard sort based on the defined field and direction.

The result is a new sorted array without modifying the original dataset, adhering to the immutability principles.

Data Expectations

The Sort Logic expects the following structure for the input data:

AI Integrations

Currently, there are no direct AI integrations associated with the Sort Logic. However, it can be a part of larger processes where machine learning predictions can be sorted as part of data preprocessing steps before analysis.

Billing Impacts

Using the Sort Logic is subject to the platform's pricing structure. Sorting operations may count towards data processing units based on the size of the dataset being sorted and the complexity of the operations (e.g., using custom comparators). Users should monitor their usage and understand how these operations contribute to their overall billing.

Use Cases & Examples

Use Case 1: Data Preparation for Reporting

Sorting customer sales data by date in ascending order to prepare a time-series report.

Use Case 2: Product Listing Optimization

Sorting a list of products based on user ratings to display top-rated products first.

Use Case 3: Ranking Employees

Sorting employee records based on performance score to present the best-performing employees in a quarterly review.

Detailed Example: Sorting Customer Sales Data

Use Case: Preparing a Report for Analysis

Configuration:

javascript
const sortNode = createSortNode({
  field: 'purchaseDate',
  direction: 'ASC',
  customOrder: undefined,
  comparator: undefined
});

Input Data:

json
[
  { "customerId": 1, "purchaseDate": "2023-10-05", "amount": 250 },
  { "customerId": 2, "purchaseDate": "2023-09-15", "amount": 450 },
  { "customerId": 3, "purchaseDate": null, "amount": 300 },
  { "customerId": 4, "purchaseDate": "2023-09-20", "amount": 150 }
]

Output from Sorting:

json
[
  { "customerId": 2, "purchaseDate": "2023-09-15", "amount": 450 },
  { "customerId": 4, "purchaseDate": "2023-09-20", "amount": 150 },
  { "customerId": 1, "purchaseDate": "2023-10-05", "amount": 250 },
  { "customerId": 3, "purchaseDate": null, "amount": 300 }
]

In this example, the input data is sorted by purchaseDate in ascending order, allowing a time-sequenced view of sales activity.