Skip to main content

URL Sorting Guidelines

In this section, users can find information about generic code that appears in different API endpoints.
We aim to explain how our system works, making this content especially useful.

We will provide a further explanation of URL sorting.

1. Overview

URL sorting provides a safe way to sort data using human-friendly URLs.

The main goal of this article is to explain an easy URL interface for sorting data. It allows users to sort data safely.

2. Operators

  • ASC [default]
    Sorting in ascending order, this should be the default ordering operator
  • DESC
    Sorting in descending order, this could be considered as a negation sort operator

3. Operands

Operands in this case can be any variable with some meaning, ex. BirthDate, Status, ...

4. Implementation

In order to describe operators we will use the increment or decrement coefficients: +1 [asc] an -1 [desc]

Since +1 === 1 we can use the sign: 1

This means:

  • ASC => 1
  • DESC => -1

Lets assume that sortFunction = F(X):

  • F(0) = 0
  • F(ASC * X) = F(X) = ASC * X = X
  • F(DESC * X) = F(-X) = DESC * X = -X

If we assume that sortUrlFunction = G(F(X)):

  • G(0) = ''
  • G(ASC X) = 'X'
  • G(DESC X) = '-X'

This will mean that:

  • F(X, Y, Z) = F1(X) + F2(Y) + F3(-Z) = ASC * X + ASC * Y + DESC * Z = X + Y - Z
  • G(X, Y, Z) = + X , + Y , - Z = 'X , Y , - Z'

Example:

  • G(ASC BirthDate, DESC Status, DESC Balance) = 'BirthDate, Status,-Balance'