Sorting of file names mainly involves sorting of file names starting with numbers, which must be sorted by the order of the preceding numbers. We can see some implementations on the Internet, many of which are traversing the values in the array, and caching the characters with numbers before conversion into numbers for comparison. Implementation is quite troublesome, and it seems difficult. When the parseint and parsefloat functions provided by JavaScript start with a number in parse, a numeric value starting with a number is returned. If not starting with a number, a nan object is returned, in this way, if the string starts with a number, you can directly useParsefloat or parseint functions return values for comparison. If the value of parse is Nan, the size can be directly compared (the default comparison is based on the ASCII character order ).
One problem left. Chinese names are sorted by pinyin letters! This problem is a little troublesome. Write it next time!