I have a set of data which is split into two arrays (let's call them data
and keys
). That is, for any given item with an index i
, I can access the data for that item with data[i]
and the key for that item with keys[i]
. I cannot change this structure (eg, to interleave keys and data into a single array), because I need to pass the data
array to a library function which expects a certain data layout.
How can I sort both arrays (preferably using standard library functions) according to the content of the keys
array?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…