# algorithms – Determining number of \$j\$ such that \$b_j le c_i\$ and \$a_j le b_i\$ in time \$O(log n)\$

I have an array $$A$$ of length $$n$$, containing triplets (think of it as a $$3times n$$ matrix). Can I re-order the array (without reordering a triplet’s inner values) in time $$O(nlog n)$$ so that it is possible to answer the following query in $$O(log n)$$? Given $$i$$, determine the number of $$j$$ such that $$A_{2,j} le A_{3,i}$$ and $$A_{1,j} le A_{2,i}$$.