Sorting multiple arrays at once

后端 未结 4 1071
醉酒成梦
醉酒成梦 2020-12-10 19:57

I have 3 arrays :

  • array 1 is \"Name\" John, Jim, Jack, Jill

  • array 2 is \"Age\" 25, 30, 31, 22

  • array 3 is \"Gender\" Male, Ma

4条回答
  •  春和景丽
    2020-12-10 20:23

    Given your constraint why not just write your own sort function. Inside the sort function maintain all the arrays like:

    1. Find the lowest item. Say it is at index 5. Now swap item@index5 with item@index0 in all 3 arrays.
    2. Repeat the above logic starting from index 1...

提交回复
热议问题