Quantcast
Channel: Active questions tagged string-manipulation - Mathematica Stack Exchange
Viewing all articles
Browse latest Browse all 186

Sorting alphanumeric strings

$
0
0

Say I have

strings = {"a16", "b22", "a8", "c1", "b18", "b2", "a1"};

Sort@strings gives {"a1", "a16", "a8", "b18", "b2", "b22", "c1"}, but I'd like to obtain {"a1", "a8", "a16", "b2", "b18", "b22", "c1"}. What's the shortes and most elegant way to do so? It could be done with StringSplit, ToExpression, Ordering etc., but this all looks like an exaggeration; I expected MMA to have something like SortBy[strings,AlphaNumericalOrder]...


Viewing all articles
Browse latest Browse all 186

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>