# tfr.utils.organize_valid_indices

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/ranking/blob/v0.5.3/tensorflow_ranking/python/utils.py#L203-L235) |

Organizes indices in such a way that valid items appear first.

    tfr.utils.organize_valid_indices(
        is_valid, shuffle=True, seed=None
    )

<br />

<br />

<br />

| ## Args ||
|---|---|
| `is_valid` | A boolean `Tensor` for entry validity with shape \[batch_size, list_size\]. |
| `shuffle` | A boolean indicating whether valid items should be shuffled. |
| `seed` | An int for random seed at the op level. It works together with the seed at global graph level together to determine the random number generation. See `tf.set_random_seed`. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| A tensor of indices with shape \[batch_size, list_size, 2\]. The returned tensor can be used with [`tf.gather_nd`](https://www.tensorflow.org/api_docs/python/tf/gather_nd) and [`tf.scatter_nd`](https://www.tensorflow.org/api_docs/python/tf/scatter_nd) to compose a new \[batch_size, list_size\] tensor. The values in the last dimension are the indices for an element in the input tensor. ||

<br />