Sorting Mixed Alphanumeric Slugs in MySQL: A Practical Guide for Real-World Applications
When working with identifiers like r1, r20, r100, or smk1, smk50, smk200, it is common to expect them to sort in a natural, human-friendly order. Unfortunately, default MySQL sorting follows pure lexicographical rules, which often leads to unintuitive results such as:
smk1
smk100
smk20
This article explains why this happens,