问题描述
有人回答我如何基于其他数组排序数组?我有一个具有相同索引的数组:希望有可能. :-)
示例:
arrFirst [5]
0 = 0001 \ r \ n测试1
1 = 0002 \ r \ n测试2
2 = 0003 \ r \ n测试3
3 = 0004 \ r \ n测试4
4 = 0005 \ r \ n测试5
arrSecond [5]
0 = 0002 \ r \ ntry1
1 = 0004 \ r \ ntry2
2 = 0005 \ r \ ntry3
3 = 0003 \ r \ ntry4
4 = 0001 \ r \ ntry5
我想根据arrFirst的顺序对arrSecond进行排序.我的排序参考是\ r \ n之前的值.意思是数字:
例如:
排序后的预期输出:
arrSecond [5]
0 = 0001 \ r \ ntry5
1 = 0002 \ r \ ntry1
2 = 0003 \ r \ ntry4
3 = 0004 \ r \ ntry2
4 = 0005 \ r \ ntry3
谢谢,
Chaegie
somebody answer me on how to sort array based on other array? i have an array which have the same index: hope it is possible. :-)
Example:
arrFirst[5]
0 = 0001\r\nThe testing1
1 = 0002\r\nThe testing2
2 = 0003\r\nThe testing3
3 = 0004\r\nThe testing4
4 = 0005\r\nthe testing5
arrSecond[5]
0 = 0002\r\nThe try1
1 = 0004\r\nThe try2
2 = 0005\r\nThe try3
3 = 0003\r\nThe try4
4 = 0001\r\nthe try5
i want to sort the arrSecond based on the sequence of arrFirst. My reference of sorting is the value before \r\n. meaning it is the number:
example:
expected output after sorting:
arrSecond[5]
0 = 0001\r\nThe try5
1 = 0002\r\nThe try1
2 = 0003\r\nThe try4
3 = 0004\r\nThe try2
4 = 0005\r\nthe try3
Thanks,
Chaegie
推荐答案
这篇关于基于其他数组的度假村数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!