Description:
Sort members of a sequence.
Syntax:
A.sort( x;loc)
A.sort(xi:di,..... ;loc)
Note:
The function sorts members of sequence A according to the value of expression x and the order of language loc. Return the original sequence A with data structure retained if it is empty. If omitting loc, then sort them by comparing their unicode values. By default, sort members in ascending order.
Parameter:
|
A |
A sequence. |
|
x |
Sorting expression. |
|
xi |
Sorting expression; when there are multiple expressions, perform the sorting according to them in order. |
|
di |
Sorting order; sort in ascending order when di >0and in descending order when di <0; default is the ascending order. |
|
loc |
Language name; case-insensitive. |
Values for loc:
|
ja_JP |
Japanese |
Japan |
|
es_PE |
Spanish |
Peru |
|
en |
English |
|
|
ja_JP_JP |
Japanese |
Japan |
|
es_PA |
Spanish |
Panama |
|
sr_BA |
Serbian |
Bosnia and Herzegovina |
|
mk |
Macedonian |
|
|
es_GT |
Spanish |
Guatemala |
|
ar_AE |
Arabic |
United Arab Emirates |
|
no_NO |
Norwegian |
Norway |
|
sq_AL |
Albanian |
Albania |
|
bg |
Bulgarian |
|
|
ar_IQ |
Arabic |
Iraq |
|
ar_YE |
Arabic |
Yemen |
|
hu |
Hungarian |
|
|
pt_PT |
Portuguese |
Portugal |
|
el_CY |
Greek |
Cyprus |
|
ar_QA |
Arabic |
Qatar |
|
mk_MK |
Macedonian |
Macedonia |
|
sv |
Swedish |
|
|
de_CH |
German |
Switzerland |
|
en_US |
English |
United States |
|
fi_FI |
Finnish |
Finland |
|
is |
Icelandic |
|
|
cs |
Czech |
|
|
en_MT |
English |
Malta |
|
sl_SI |
Slovenian |
Slovenia |
|
sk_SK |
Slovak |
Slovakia |
|
it |
Italian |
|
|
tr_TR |
Turkish |
Turkey |
|
zh |
Chinese |
|
|
th |
Thai |
|
|
ar_SA |
Arabic |
Saudi Arabia |
|
no |
Norwegian |
|
|
en_GB |
English |
United Kingdom |
|
sr_CS |
Serbian |
Serbia and Montenegro |
|
lt |
Lithuanian |
|
|
ro |
Romanian |
|
|
en_NZ |
English |
New Zealand |
|
no_NO_NY |
Norwegian Norway |
Nynorsk |
|
lt_LT |
Lithuanian |
Lithuania |
|
es_NI |
Spanish |
Nicaragua |
|
nl |
Dutch |
|
|
ga_IE |
Irish |
Ireland |
|
fr_BE |
French |
Belgium |
|
es_ES |
Spanish |
Spain |
|
ar_LB |
Arabic |
Lebanon |
|
ko |
Korean |
|
|
fr_CA |
French |
Canada |
|
et_EE |
Estonian |
Estonia |
|
ar_KW |
Arabic |
Kuwait |
|
sr_RS |
Serbian |
Serbia |
|
es_US |
Spanish |
United States |
|
es_MX |
Spanish |
Mexico |
|
ar_SD |
Arabic |
Sudan |
|
in_ID |
Indonesian |
Indonesia |
|
ru |
Russian |
|
|
lv |
Latvian |
|
|
es_UY |
Spanish |
Uruguay |
|
lv_LV |
Latvian |
Latvia |
|
iw |
Hebrew |
|
|
pt_BR |
Portuguese |
Brazil |
|
ar_SY |
Arabic |
Syria |
|
hr |
Croatian |
|
|
et |
Estonian |
|
|
es_DO |
Spanish |
Dominican Republic |
|
fr_CH |
French |
Switzerland |
|
hi_IN |
Hindi |
India |
|
es_VE |
Spanish |
Venezuela |
|
ar_BH |
Arabic |
Bahrain |
|
en_PH |
English |
Philippines |
|
ar_TN |
Arabic |
Tunisia |
|
fi |
Finnish |
|
|
de_AT |
German |
Austria |
|
es |
Spanish |
|
|
nl_NL |
Dutch |
Netherlands |
|
es_EC |
Spanish |
Ecuador |
|
zh_TW |
Chinese |
Taiwan |
|
ar_JO |
Arabic |
Jordan |
|
be |
Belarusian |
|
|
is_IS |
Icelandic |
Iceland |
|
es_CO |
Spanish |
Colombia |
|
es_CR |
Spanish |
Costa Rica |
|
es_CL |
Spanish |
Chile |
|
ar_EG |
Arabic |
Egypt |
|
en_ZA |
English |
South Africa |
|
th_TH |
Thai |
Thailand |
|
el_GR |
Greek |
Greece |
|
it_IT |
Italian |
Italy |
|
ca |
Catalan |
|
|
hu_HU |
Hungarian |
Hungary |
|
fr |
French |
|
|
en_IE |
English |
Ireland |
|
uk_UA |
Ukrainian |
Ukraine |
|
pl_PL |
Polish |
Poland |
|
fr_LU |
French |
Luxembourg |
|
nl_BE |
Dutch |
Belgium |
|
en_IN |
English |
India |
|
ca_ES |
Catalan |
Spain |
|
ar_MA |
Arabic |
Morocco |
|
es_BO |
Spanish |
Bolivia |
|
en_AU |
English |
Australia |
|
sr |
Serbian |
|
|
zh_SG |
Chinese |
Singapore |
|
pt |
Portuguese |
|
|
uk |
Ukrainian |
|
|
es_SV |
Spanish |
El Salvador |
|
ru_RU |
Russian |
Russia |
|
ko_KR |
Korean |
South Korea |
|
vi |
Vietnamese |
|
|
ar_DZ |
Arabic |
Algeria |
|
vi_VN |
Vietnamese |
Vietnam |
|
sr_ME |
Serbian |
Montenegro |
|
sq |
Albanian |
|
|
ar_LY |
Arabic |
Libya |
|
ar |
Arabic |
|
|
zh_CN |
Chinese |
China |
|
be_BY |
Belarusian |
Belarus |
|
zh_HK |
Chinese |
Hong Kong |
|
ja |
Japanese |
|
|
iw_IL |
Hebrew |
Israel |
|
bg_BG |
Bulgarian |
Bulgaria |
|
in |
Indonesian |
|
|
mt_MT |
Maltese |
Malta |
|
es_PY |
Spanish |
Paraguay |
|
sl |
Slovenian |
|
|
fr_FR |
French |
France |
|
cs_CZ |
Czech |
Czech Republic |
|
it_CH |
Italian |
Switzerland |
|
ro_RO |
Romanian |
Romania |
|
es_PR |
Spanish |
Puerto Rico |
|
en_CA |
English |
Canada |
|
de_DE |
German |
Germany |
|
ga |
Irish |
|
|
de_LU |
German |
Luxembourg |
|
de |
German |
|
|
es_AR |
Spanish |
Argentina |
|
sk |
Slovak |
|
|
ms_MY |
Malay |
Malaysia |
|
hr_HR |
Croatian |
Croatia |
|
en_SG |
English |
Singapore |
|
da |
Danish |
|
|
mt |
Maltese |
|
|
pl |
Polish |
|
|
ar_OM |
Arabic |
Oman |
|
tr |
Turkish |
|
|
th_TH_TH |
Thai |
Thailand TH |
|
el |
Greek |
|
|
ms |
Malay |
|
|
sv_SE |
Swedish |
Sweden |
|
da_DK |
Danish |
Denmark |
|
es_HN |
Spanish |
Honduras |
Option:
|
@u |
Create multi-level sorting based on specified fields and according to the original order in which records first appear. |
|
@m |
Use parallel algorithm to enhance performance to handle data-intensive and computation-intensive tasks. |
|
@z |
Sorting in descending order. |
|
@n |
The option can increase the numbering efficiency, but can only be used when the specified expression returns a positive integer; support using sequence numbers. |
|
@0 |
Put a null-value member or records with null values at the end. |
|
@v |
Return result as a pure table sequence when sequence A is a pure table sequence; return a pure sequence by default. Only supported by esProc Enterprise Edition. |
Return value:
Sequence
Example:
|
|
A |
|
|
1 |
=[2,1,3,8,6,5] |
|
|
2 |
=A1.sort() |
[1,2,3,5,6,8]. |
|
3 |
=["s","e","a","d"].sort(;"en") |
[a,d,e,s]. Sort the sequence by the English language specified by “en”. |
|
4 |
=demo.query("select * from EMPLOYEE ") |
|
|
5 |
=A4.sort(DEPT,BIRTHDAY:-1) |
First sort the sequence by DEPT in ascending order, and then sort it by BIRTHDAY in descending order. |
|
6 |
=file("D:/txt/test1.txt").import@t() |
|
|
7 |
=A6.sort@u(f1,f2,f3) |
Create multi-level sorting according to the fields f1, f2 and f3 in the original order.
|
|
8 |
=demo.query("select * from EMPLOYEE") |
|
|
9 |
=A8.sort@m(DEPT,BIRTHDAY:-1) |
Use @m option to increase performance of big data handling. |
|
10 |
=A1.sort@z() |
[8,6,5,3,2,1]. |
|
11 |
=[2,1,3,,8,6,5] |
|
|
12 |
=A11.sort() |
[null,1,2,3,5,6,8]. |
|
13 |
=A12.sort@0() |
[1,2,3,5,6,8,null]. |
Related function: