7.1 Sort a sequence
1. Sort in ascending order
2. Sort in descending order
3. Position after sorting
4. Random sorting
SPL
A | B | |
---|---|---|
1 | [13,30,45,23,42,98,61] | |
2 | =A1.sort() | [13,23,30,42,45,61,98] |
3 | =A1.sort@z() | [98,61,45,42,30,23,13] |
4 | =A1.psort() | [1,4,2,5,3,7,6] |
5 | =A1.sort(rand()) | [30,13,98,45,42,23,61] |
SQL
1. Sort in ascending order
SELECT *
FROM TABLE(sys.odcinumberlist(13,30,45,23,42,98,61))
ORDER BY COLUMN_VALUE;
2. Sort in descending order
SELECT *
FROM TABLE(sys.odcinumberlist(13,30,45,23,42,98,61))
ORDER BY COLUMN_VALUE DESC;
3. Position after sorting
SELECT rn FROM(
SELECT seq.*,ROWNUM AS rn
FROM TABLE(sys.odcinumberlist(13,30,45,23,42,98,61)) seq)
ORDER BY COLUMN_VALUE;
4. Random sorting
SELECT *
FROM TABLE(sys.odcinumberlist(13,30,45,23,42,98,61))
ORDER BY dbms_random.value;
Python
seq = np.array([13, 30, 45, 23, 42, 98, 61])
seq_sorted_ascending = np.sort(seq) #[13,23,30,42,45,61,98]
seq_sorted_descending = np.sort(seq)[::-1] #[98,61,45,42,30,23,13]
sorted_positions = np.argsort(seq) #[0 3 1 4 2 6 5]
seq_random = np.random.permutation(seq) #[61 45 98 13 23 42 30]
7.2 Sort the structured data
Example codes for comparing SPL, SQL, and Python
SPL Official Website 👉 https://www.scudata.com
SPL Feedback and Help 👉 https://www.reddit.com/r/esProc_SPL
SPL Learning Material 👉 https://c.scudata.com
SPL Source Code and Package 👉 https://github.com/SPLWare/esProc
Discord 👉 https://discord.gg/cFTcUNs7
Youtube 👉 https://www.youtube.com/@esProc_SPL