Human sorting, hardened

· Ned Batchelder · Nov. 25, 2026, 1:11 p.m.
Summary
This blog post discusses the challenges of maintaining a 'human sorting' function in Python that sorts strings with numeric components in a way that aligns with human expectations. The author shares insights on a specific edge case where excessively long digit sequences hinder sorting and describes the adjustments made to improve the sorting function. By examining the limitations of Python's int conversion and proposing an alternative that avoids potential errors, the author highlights the balance between fixing bugs and prioritizing real-world usability. This post reveals personal reflections on coding practices and the pitfalls of over-fixing edge cases.