01-11-2026 10:38 AM - edited 01-11-2026 10:41 AM
Both methods have problems sorting numbers that have differing numbers of digits past the decimal point. For example, 10.425 becomes 10.000000425, while 10.422425 becomes 10.0000422425. That I can control easily by formatting any numbers with a fixed number of decimal places.
But both methods also have trouble with negative numbers, and I haven't figured out how to fix that yet...
01-11-2026 10:46 AM
@FlatCat wrote:
Both methods have problems sorting numbers that have differing numbers of digits past the decimal point. For example, 10.425 becomes 10.000000425, while 10.422425 becomes 10.0000422425. That I can control easily by formatting any numbers with a fixed number of decimal places.
But both methods also have trouble with negative numbers, and I haven't figured out how to fix that yet...
I never considered supporting fractional numbers. (But I might start thinking about it.)
01-11-2026 11:17 AM
It is not expected to work with floating point numbers, but that can be solved once we know what's allowed.
Can we assume that your floating point fields don't have any alphabetic characters, or can they also be "mixed" (e.g. "10.456OHM" , "ABC=1.456", etc. "R.45AX:, etc.) Of course if they have an "E", they might be in exponential format.
Note that my sorting is most useful for filenames, mirroring the default behavior of windows explorer (e.g. file names have other periods, delimiting the file extension, so you need to be careful.)
01-11-2026 11:30 AM - edited 01-11-2026 12:26 PM
If we can assume that floating point numbers are cleanly formatted, here's what you could do:
Basically, we check if scanning the fields as floating point gives no error or no remaining string. Please test! No guarantees. Works fine with negative numbers, integers, and floating point in any recognized format.
01-11-2026 11:34 AM
@altenbach wrote:
Yes, I got the gist of it from the picture
You are padding with spaces (i.e. a non-numeric character) while I am padding with zeroes (i.e. a numeric character)..
I am curious if there could be edge cases where it would make a difference, but haven't explored that.
One simplification would be to use the upper input of the format, eliminating your inner concatenation.
I briefly thought about space vs zero, but quickly convinced myself that it would be OK.
01-11-2026 12:24 PM - edited 01-11-2026 12:32 PM
It's probably sufficient just to check for error and switch mode when an error occurs:
You might want to implement some error handling to ensure that all fields were processed with the same algorithm. (not shown).
01-11-2026 12:32 PM
This works. But, as I mentioned a few comments back when I described my first solution, I actually know beforehand whether the chosen column contains purely numeric or alphanumeric data. So I can chose the method on that basis. But the error check is nice if I just want to go by the contents of the table itself.
01-11-2026 11:37 PM
Try this. Works with floats, scientifics, arbitrary number width.