In `_get_next_random_batch()`, the `remaining_entities` and `remaining_entity_weights` lists were being constructed by iterating sets. This patch changes the function to iterate a sorted copy of each set instead.
In `_get_next_random_batch()`, the `remaining_entities` and `remaining_entity_weights` lists were being constructed by iterating sets. This patch changes the function to iterate a sorted copy of each set instead.