简体   繁体   中英

How to sort a 2D array by rows and store indices in new 2d array

I have an array of dimension (43, 25520).

I want to sort them for every of those 43 columns and then store the sorted indices for every row in a new 2d array. So the output should be a new sorted (43, 25520).

first_sorted = np.argsort(active_genevector[2,:])

With that I get the sorted 25520 indices of the first of 43 rows.

How can I do that to get in the end it for all 43 as a (43, 25520) array?

I made a short script to test what you need:

import numpy as np

test = np.random.random((43,25520))

result = np.argsort(test, axis = 1)

print(result.shape)

I think this would work for you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM