diff --git a/tools/filters/sorter.py b/tools/filters/sorter.py index b351aa506a9..a3ac7e9cdd2 100644 --- a/tools/filters/sorter.py +++ b/tools/filters/sorter.py @@ -26,19 +26,20 @@ def main(): try: inputfile = options.input outputfile = '-o %s' % options.out_file1 - order = ('', '-r')[options.order == 'DESC'] columns = [options.column] styles = [('','n')[options.style == 'num']] - col_styles = sys.argv[6:] - if len(col_styles) > 1: - columns.extend([col_styles[i] for i in range(0,len(col_styles),2)]) - styles.extend([('','n')[col_styles[i] == 'num'] for i in range(1,len(col_styles),2)]) - cols = [ '-k%s,%s%s'%(columns[i], columns[i], styles[i]) for i in range(len(columns)) ] + orders = [('','r')[options.order == 'DESC']] + col_style_orders = sys.argv[6:] + if len(col_style_orders) > 1: + columns.extend([col_style_orders[i] for i in range(0,len(col_style_orders),3)]) + styles.extend([('','n')[col_style_orders[i] == 'num'] for i in range(1,len(col_style_orders),3)]) + orders.extend([('','r')[col_style_orders[i] == 'DESC'] for i in range(2,len(col_style_orders),3)]) + cols = [ '-k%s,%s%s%s'%(columns[i], columns[i], styles[i], orders[i]) for i in range(len(columns)) ] except Exception, ex: stop_err('Error parsing input parameters\n' + str(ex)) # Launch sort. - cmd = "sort -f -t $'\t' %s %s %s %s" % (order, ' '.join(cols), outputfile, inputfile) + cmd = "sort -f -t $'\t' %s %s %s" % (' '.join(cols), outputfile, inputfile) try: os.system(cmd) except Exception, ex: diff --git a/tools/filters/sorter.xml b/tools/filters/sorter.xml index b9b22faec25..e176f6d8428 100644 --- a/tools/filters/sorter.xml +++ b/tools/filters/sorter.xml @@ -10,6 +10,7 @@ #for $col in $column_set: ${col.other_column} ${col.other_style} + ${col.other_order} #end for @@ -19,17 +20,21 @@ + + + + + + + + - - - - @@ -39,18 +44,20 @@ + - + + - + @@ -64,7 +71,7 @@ **Syntax** -This tool sorts the dataset on any number of columns in either ascending or descending order (all columns will be ascending or descending). +This tool sorts the dataset on any number of columns in either ascending or descending order. * Numerical sort orders numbers by their magnitude, ignores all characters besides numbers, and evaluates a string of numbers to the value they signify. * Alphabetical sort is a phonebook type sort based on the conventional order of letters in an alphabet. Each nth letter is compared with the nth letter of other words in the list, starting at the first letter of each word and advancing to the second, third, fourth, and so on, until the order is established. Therefore, in an alphabetical sort, 2 comes after 100 (1 < 2).