Optimized the natural sort comparing function