tfp.stats.iterative_mergesort

Non-recusive mergesort that counts exchanges.

y a Tensor of shape [n] containing values to be sorted.
permutation Tensor of shape [n] with original ordering.
name Optional Python str name for ops created by this method. Default value: None (i.e., 'iterative_mergesort').

exchanges int32 scalar that counts the number of exchanges required to produce a sorted permutation
permutation and a tf.int32 Tensor that contains the ordering of y values that are sorted.