Remove the use of srand by localizing random ordering logic