Stream: helpdesk (published)

Topic: invert `sortperm`


view this post on Zulip Alessandro Cheli (Feb 03 2022 at 08:37):

sortperm for a vector gives me a permutation that sorts an array

x = rand(1:10, 5)
p = sortperm(x)
x[p] # is sorted

How can i generate a permutation q from p such that

x[p][q] == x

?

view this post on Zulip Felix Kastner (Feb 03 2022 at 08:39):

Maybe [Base.invperm] (https://docs.julialang.org/en/v1/base/arrays/#Base.invperm)?

view this post on Zulip Alessandro Cheli (Feb 03 2022 at 08:40):

TY! Didn't find it in docs :)


Last updated: Nov 22 2024 at 04:41 UTC