Sorting a list of file names so that file 10 comes after file 9
Take a folder of exported photos: IMG 1.jpg, IMG 2.jpg and so on up to IMG 12.jpg. Paste the names into most sort tools and you get IMG 1, IMG 10, IMG 11, IMG 12, IMG 2, IMG 3. The tool is not broken. It compares the names one character at a time, and the character "1" comes before "2", so every name that starts with IMG 1 lands before IMG 2.
People do not read numbers that way. A run of digits is one number, and 10 is bigger than 2. The default A to Z order here works the same way: when two lines reach digits at the same place, it compares the whole numbers. The photo list comes back as IMG 1, IMG 2, IMG 3 and on to IMG 12, which is the order a camera took them in. This is often called a natural sort.
A different job is sorting by the number itself. Paste a price list such as "Tea $4.50", "Cake $12", "Coffee $3" and pick By number, smallest first. The tool reads the first number on each line, so the list becomes Coffee, Tea, Cake. Commas inside a number are read as thousands, so "1,200 visits" sorts as 1200. A line with no number, such as a heading, goes to the end rather than being treated as zero.
Sorting by length helps with less obvious jobs. Longest line first puts the longest names in a list at the top, which shows what will not fit a column or a label. Shortest line first is a quick way to find stray one-letter lines left over from a bad copy and paste. With Remove duplicates on, the list is cleaned and sorted in one step, and the note under the result says how many lines went.
The tool has limits. The A to Z order follows English dictionary rules, so it will not match the order of a language with different rules, such as Swedish, where å comes after z. It reads only the first number on a line, so "2 of 10" sorts by the 2. It takes up to 1 MB of text at a time. Above that, split the file and sort each part.