I want to sort an array of strings that contain names and numbers. But I want to improve the alphanumerical sort order to get an order like
John 8 test
John 9 test
John 10 test
instead of having "John 10 test" at the top because "1" < "8" < "9". My idea is to insert the number of digits of a number bevore any number so internally the array to be sorted becomes:
John 18 test
John 19 test
John 210 test
which now is an alphanumeric correctly sorted array.
Any ideas how to insert the number of digits bevore the numer in an easy way? RegExp would be perfect. I am doing all this in nodejs/JavaScript.
Thanks in advance!
heinob