主页  »  技术支持  »  指南/使用技巧  »  UltraEdit  »  Advanced and column-based sort
IDM Power Tips

Advanced file sort

UltraEdit has a powerful sort engine that allows you to sort file large amounts of file data based on several "keys" that may be set. By default, UltraEdit will sort a file alphabetically by looking at the first character of the line. In the tutorial below, we will take a look at some of the advanced sort options that allow you to sort data based on a specific column or block of data.

Advanced File Sort: Column-Based Sort

UltraEdit can perform sorting tasks on large files, but for the purpose of this tutorial we will be using a small amount of sample data. As you can see below, this sample data includes a name, a monetary amount, and a tax amount in fixed columns.

Advanced File Sort:  Column-Based Sort

For advanced sort options, it will be necessary to convert your data to fixed column widths. If your data is not organized in fixed columns, you can got to Column : Convert to Fixed Column to achieve this.

For more information on converting data fields to fixed width, visit our Power Tip Working with CSV Files.


1. The Basic Sort

You can access the sort options under File : Advanced Sort/Options.

Advanced File Sort:  Column-Based Sort

The default values for the Advanced Sort/Options are shown below. Within this dialog, you can configure the sort to be ascending or descending. You can also set options to remove duplicates, ignore case, or perform a numeric sort.

Sort Order (Ascending/descending)

This sets the sort for ascending or descending order. "Ascending" is the default.

Remove duplicates

If this is checked, any lines that are found to be identical to another are removed, the first line is preserved. If the Ignore Case option is set, lines are considered identical if the characters are the same with the only difference being the case of them.

Ignore case

This option should be checked if you want the search to be insensitive to case, i.e. "CAT" is considered the same as "cat". Do not check this option if the sort should consider "CAT" different from "cat".

Numeric Sort

If this is checked, the sort will perform a numeric sort on the selected columns. Typically a sort is non-numeric and the values 1,11,111 would be sorted before 2,22,222 as 1 comes before 2. If a numeric sort is selected, the values would be sorted in numeric order (1,2,11,12,111,222). The numeric sort is not possible with a locale specific sort or when using the alternate sort method.

Advanced File Sort:  Column-Based Sort

Click the "Sort" button to sort your file based on the configurations in the Advanced Sort/Options dialog. Below is a screenshot of our sample data after a sort with UltraEdit's default settings.

Advanced File Sort:  Column-Based Sort


2. Sort Using a Key

In our hypothetical scenario, we would like to sort our file based on the main monetary amount, not the individual's name. In order to do this, we will need to access the Advanced Sort/Options again and set a key.

A key is a a range of columns that will be used to sort the entire file. While UltraEdit will only look at the predefined column you set here, it will sort the entire line and not just the column data. You can specify up to 4 hierarchical keys for a single sort. UltraEdit will look at Key 1 first. If the data between two lines is identical, UltraEdit will then look at Key 2, then Key 3, and finally Key 4.

In our example, the column data for our key exists between columns 20 and 28. Therefore we will enter "20" for the Start Column and "28" for the End Column.

Advanced File Sort:  Column-Based Sort

Clicking the "Sort" button gives us the output shown below.

Advanced File Sort:  Column-Based Sort


3. Sort Using Multiple Keys

Finally, we'd like to not only sort our sample data based on the main monetary amount, but on the tax amount as well. This is easy to do - we will enter the Start Column "32" (where our sample tax data begins) and the End Column "-1". Setting a value of "-1" will cause UltraEdit to look to the absolute end of the line.

Advanced File Sort:  Column-Based Sort

After clicking "Sort", our output is shown below.

Advanced File Sort:  Column-Based Sort

That's all there is to sorting columns - a very powerful and easy way of sorting your text data.


Back to power tips index


Buy Now
Upgrade
Download

应用导航

UltraEdit feature maps
全新功能

Cnet/Download.com review of UltraEdit
"我们并没有夸大其词:
UltraEdit真的非常棒..."

节省将近50%

IDM Software Bundles

在UltraEdit基础上绑定其它的产品许可节省将近50%

旅行, 任何人?

UE3 software

UE3和您的UltraEdit捆绑一起升级,节省将近50%或者更多!


Take the UltraEdit tour