I have a set of alphanumeric strings that I need to sort in Python. I know that I can use the sorted()
function to sort lists, but sets don’t have a specific order, so I’m not sure how to proceed.
Here’s an example set that I’m working with:
my_set = {'item2', 'item10', 'item1', 'item5', 'item11'}
In this code, I define a set my_set
with five alphanumeric strings. I want to sort this set in ascending order based on the alphanumeric values.
Could someone please suggest a way to sort this set in Python? I’m open to any suggestions. Thank you!