Sort Lines in Files

Sort Lines has many options to control how the sorting should be done. It will sort lines in all selected text files. The number of files it will try to sort is shown in the dialog.

Sort Lines will automatically identify file formats: files encoded in ASCII/Unicode/UTF8 are supported. Note that files identified as binary will be ignored.
The newline character(s) that the file currently has will be kept, So if a file has only CR (carriage return) as a newline character the new file will also have only CR.

In the Filename field you set what the name of the sorted file will be. Sorted files will always be saved in the same folder as the original and only the Filename can be set: the original extension will be kept.

If multiple files are select you will see a "*" in the Filename field. The * represents the original Filename and file extension.
If you have two files select named "MyFile1.txt" and "MyFile2.txt" and the Filename field has the value "*_sorted.*" the new Filenames will be "MyFile1_sorted.txt" and "MyFile2_sorted.txt".

In the Save as... dropdown list you can select to save the new file with a different name. You can also choose to keep the original name (but rename the original files by adding .bak to its name), or it can delete the original file.

Lines and Position limits

Keep lines at the top

This defines how many line at the top of each file that should not be sorted. For example, if you have a header in the text file that is 2 lines high you can set this to "2". The new, sorted file will then still have a 2-line header.

Keep lines at the bottom

This defines how many lines at the bottom of each file that should not be sorted. For example, if you have a 3-line footer text this option will ensure that those 3 lines are not moved by sorting.

Start at line position

Where on each line the sorting should begin. If lines should not be sorted beginning at character 1, you can control at which position it should begin. Changing this settings will change the position of the "*" character in the preview ruler at the bottom of the dialog. This shows clearly at what position sorting will begin.

Skip Leading spaces

By checking this option all leading white spaces will be ignored when comparing lines during search.

Sort lines by

There are 3 different ways to sort lines: Entire line, Substring or by Line item (record)

Entire line

This will compare the entire line from the defined start position to the end.

Substring, Substring ends at

This can be used if sorting should be based on a specific substring in a text.
Use the option above "Start at line position" to set the beginning of the substring.
Then use any of the following settings to set where the end of the string is.

Fixed length

If the substring that the sorting is based on has a fixed length you can define it here.

End character

If the substring that the sorting is based on should end when it comes to a specific character.

Any white space character

If the substring that the sorting is based on ends when any white space character is found.

Line Item

If every line has items (records) that are separate by a special character you can defined which item/record it should be sorted by.

Item separator

Which character will separate the items (records) from each other. (Eg. for a comma-separated list, that would be comma "," ).


Which item on the line the sorting should be based one First item is 1, second is 2, and so on.


Sort Method

There are three methods to sort by: Text,Date and Number.


The text to be compared for sorting is plain text.


The text that will be compared for sorting is actually a date or time written as text.
To be able to compare date/time correctly the correct date/time formatting of the date/time must be provided. If the date/time matching format is not correct the sorting will not be correct.
Press the "<" button under the dropdown list for examples of date/time matching formats to use.

Date Format - Time Format


The text that will be compare is actually numbers: the number will be compared as a digital value and not as text. Leading zeros (0) will be ignored: only digits will be used.

Language-based sort order

Use the sorting rule that the current language uses. Different languages sort characters in different orders. Checking this option will cause the sort to be done using the current language settings. This sorting is slower and can affect performance for very large files.
This options will also disable the "Ignore case" option. Language-based sort order always ignores case.

Ignore case

Ignore case when sorting. "A" and "a" will be treated as the same character (but see 'Language-based sort order' above).

Natural number order

Sort numbers in a natural order. This option also requires the option "Language-based sort order".
Instead of being sorted in the order "Text1","Text10","Text2" it will be "Text1", "Text2", "Text10".
(This option is is not used if sort method is Numbers).

Reverse order

Reverse the sort order. By default sorting will be A to Z and 0 to 9.
Enabling this will cause sort order to be Z to A, and 9 to 0

Remove duplicate lines

This option is not yet enabled

Remove blank lines

After sorting the lines, remove all blank lines.