Series.argSort
Return the integer indices that would sort the Series values
danfo.Series.argSort(options)
Parameters
Type
Description
Default
options
Object
ascending: How to sort the indices
{ ascending: true
}
Returns: Series (int element)
Example
Node
1
const dfd = require("danfojs-node")
2
3
let data = [10, 45, 20, 10, 23, 20, 30, 11]
4
let sf = new dfd.Series(data)
5
6
sf.argSort().print() //defaults to ascending order
7
sf.argSort({ ascending: false }).print()
Copied!
Output
1
╔═══╤═══╗
2
║ 0 │ 3 ║
3
╟───┼───╢
4
║ 1 │ 0 ║
5
╟───┼───╢
6
║ 2 │ 7 ║
7
╟───┼───╢
8
║ 3 │ 5 ║
9
╟───┼───╢
10
║ 4 │ 2 ║
11
╟───┼───╢
12
║ 5 │ 4 ║
13
╟───┼───╢
14
║ 6 │ 6 ║
15
╟───┼───╢
16
║ 7 │ 1 ║
17
╚═══╧═══╝
18
19
╔═══╤═══╗
20
║ 0 │ 1 ║
21
╟───┼───╢
22
║ 1 │ 6 ║
23
╟───┼───╢
24
║ 2 │ 4 ║
25
╟───┼───╢
26
║ 3 │ 2 ║
27
╟───┼───╢
28
║ 4 │ 5 ║
29
╟───┼───╢
30
║ 5 │ 7 ║
31
╟───┼───╢
32
║ 6 │ 0 ║
33
╟───┼───╢
34
║ 7 │ 3 ║
35
╚═══╧═══╝
Copied!
Copy link