1. Create a list to choose from by appending the next larger element to your previous list.
2. Randomly select any element from that list.
3. Append that selection to your old list.
4. Optionally sort the result
OR all wrapped up into a single line:
Take that function apart piece by piece until you understand how it was constructed and how it works.