• esProc
Tutorial
Function Reference
Code Reference
User Reference
External Library Guide
Data File Tool Manual
DQL Tutorial
Cluster Server Manager Manual
SPL WIN Manual
• YModel
User Reference
JSON-style Parameter Guide
• ReportLite
User Reference
• Official Website

# psort()

Here’s how to use psort() function.

## A.p sort()

Description:

Get the original positions of the sorted members of a sequence.

Syntax:

A.psort (x)

A.psort(xi:di,...)

Note:

The function sorts members of sequence A according to the value of expression x and returns their sequence numbers before they are sorted.

Parameter:

 A A sequence x The sorting expression xi If there are multiple sorting expressions, they can be written as xi:di,.., a compound expression consisting of multiple expressions di Sorting order: >0 represents ascending order, which is the default, and <0 descending order

Option:

 @m Perform parallel algorithm to enhance performance of handling data-intensive or computation-intensive tasks @z Sort a sequence in descending order and return the position of a member in the original sequence @0 Put records with null values at the end

Return value:

Sequence

Example:

 A 1 [a,c,e,g,f,d,b] 2 =A1.psort(~) [1,7,2,6,3,5,4]. 3 =demo.query("select * from EMPLOYEE") 4 =A3.psort(DEPT:1,BIRTHDAY:-1) A3 is sorted in ascending order by DEPT first, and then in descending order by BIRTHDAY. 5 =A3.psort@m(DEPT,BIRTHDAY) Use @m option to increase performance of big data handling. 6 =A1.psort@z(~) [4,5,3,6,2,7,1]. 7 [a,c,e,,f,d,b] 8 =A7.psort(~) [4,1,7,2,6,3,5]. 9 =A7.psort@0(~) [1,7,2,6,3,5,4].

Related function: