I have three nested arrays, containing around 10,000
elements (each array has a different number of elements). These arrays are ordered with respect to the 0th
element and the 1st
element in each inner list has no real pattern.
So for example,
a = np.array([[1,13],[2,36],[5,63],[10,35],[11,2]...])
b = np.array([[1,13],[3,32],[7,55],[10,30],[13,21],[15,10]...])
c = np.array([[2,10],[4,36],[5,58],[8,5]...])
What i need to do is combine the arrays and then sort them with respect to the 0th element. I know of a simple method using
D = np.concatenate((a,b,c))
to combine them, and then using,
D_sort =sorted(D, key = itemgetter(0))
to sort them w.r.t the 0th element. However, this is very time consuming, and I have been wondering if there is a solution using the fact that the 0th element in each array a,b and c are sorted.
So to reiterate, is there an efficient method of combining three nested arrays and sort them w.r.t the 0th element given that the 0th element in each individual array is already sorted?
For the example given, the output would be,
[([ 1, 13], [ 1, 13],[ 2, 36],[ 2, 10],[ 3, 32],[ 4, 36],[ 5, 63],[ 5, 58],[ 7, 55],[8, 5],[10, 35],[10, 30],[11, 2],[13, 21],[15, 10])]