Coming soon - Get a detailed view of why an account is flagged as spam!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

1
Sorting alphabetically with numbers included
Post Body

I have a list of strings which include numbers that I would like sorted alphanumerically, i.e. ["Foo100", "Foo2", "Foo1"] should be sorted to ["Foo1", "Foo2", "Foo100"]. A number of suggestions on Google suggest splitting the string at some known point, but my strings are an awkward bunch that would require several custom string splitting methods. Is there an existing method (or one line bit of Python magic) that will come out with the expected answer for an arbitrary set of strings, or do I need to go forth and do some coding?

A subset of the data would be:

["55 Cnc", "CoRoT-01", "CoRoT-02", "CoRoT-11", "GJ 436", "GJ 3470", "HAT-P-01", "HAT-P-11", "HAT-P-46", "HD 17156", "HD 80606", "HD 149026", "HD 189733", "K2-03", "K2-19", "Kepler-8", "Kepler-13", "Kepler-68", "Kepler-89", "Kepler-419", "WASP-10", "WASP-11", "WASP-103"]

This is the order I would expect them to be sorted into, the original order being fairly random.

Edit: The term for the sort I wanted was natural sort, and plugging that into Google gives plenty of suggestions (mostly including re and natsort as mentioned by the comments below).

Author
Account Strength
100%
Account Age
12 years
Verified Email
Yes
Verified Flair
No
Total Karma
52,969
Link Karma
1,997
Comment Karma
50,814
Profile updated: 4 days ago
Posts updated: 9 months ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
8 years ago