title: How to sort a batch of 2D tensors in tensorflow?
body: <p>I have a tensor <code>A</code> with the shape of <code>[#batch, #MaxSequence, #Features]</code>, where the actual lengths of the 2nd dimension (may be less than <code>#MaxSequence</code>) are stored in a tensor <code>L</code>. I want to sort <code>A</code> by the 2nd feature in the 3rd dimension on the sequence in each batch. I saw this <a href="https://stackoverflow.com/questions/40784941/sorting-an-array-in-tensorflow">post</a> using <code>tf.gather</code> and <code>tf.nn.top_k</code> to sort a 2D tensor, but I don't know to apply it on the 3D case. Do I need to use loop to do it?</p>