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 DataSorter.AddKey(int key, SortOrder order, String customList) method. However, this method works only if the items in the custom list do not have commas inside them. If they have commas like “USA,US”, “China,CN” etc., then you must use **DataSorter.AddKey Method (Int32, SortOrder,String[])**) method. Here, the last parameter is not String but an Array of Strings.

Sort Data in Column with Custom Sort List

The following sample code explains how to use **DataSorter.AddKey Method (Int32, SortOrder,String[])**) method to sort data with custom sort list. Please see the sample Excel file used in this code and output Excel file generated by it. The following screenshot shows the effect of the code on the sample Excel file on execution.

todo:image_alt_text

Sample Code