Sort Data in Column with Custom Sort List

Possible Usage Scenarios

You can sort data in the column using a custom list. This can be done using the DataSorter.addKey method. However, this method works only if the items in the custom list do not have commas inside them. If they have commas, such as “USA,US”, “China,CN”, etc., then you must use DataSorter.addKey(number, SortOrder, string[]) method. Here, the last parameter is not a String but an Array of Strings.

Sort Data in Column with Custom Sort List

The following sample code explains how to use the DataSorter.addKey(number, SortOrder, string[]) method to sort data with a custom sort list. Please see the sample Excel file used in this code and the output Excel file generated by it. The following screenshot shows the effect of the code on the sample Excel file when executed.

todo:image_alt_text

Sample Code