Reversed order sorting
This commit is contained in:
parent
1c9ac7c867
commit
93d7af3aea
6
wani.py
6
wani.py
|
@ -813,7 +813,9 @@ class Writer:
|
|||
self.without_rep = args.without_rep
|
||||
self.output_file = args.output
|
||||
self.multiple_output = args.multiple_output
|
||||
|
||||
self.sort_by = int(args.sort_by)
|
||||
self.sort_order = args.sort_reversed
|
||||
|
||||
def header(self):
|
||||
cols = ["Lemma"]
|
||||
|
@ -863,7 +865,7 @@ class Writer:
|
|||
except ValueError:
|
||||
key=lambda row: row[self.sort_by].lower()
|
||||
|
||||
return sorted(rows, key=key)
|
||||
return sorted(rows, key=key, reverse=self.sort_order)
|
||||
|
||||
def write_header(self, file_handler):
|
||||
file_handler.write(", ".join(self.header()) + "\n")
|
||||
|
@ -1050,7 +1052,9 @@ if __name__ == '__main__':
|
|||
parser.add_argument('--verbose', help='Enable verbose output to stderr', choices=["warning", "info", "debug"], default="info")
|
||||
parser.add_argument('--count-files', help="Count files: more verbose output", action='store_true')
|
||||
parser.add_argument('--multiple-output', help='Generate one output for each syntactic structure', action='store_true')
|
||||
|
||||
parser.add_argument('--sort-by', help="Sort by a this column (index)", type=int, default=-1)
|
||||
parser.add_argument('--sort-reversed', help="Sort in reversed ored", action='store_true')
|
||||
|
||||
parser.add_argument('--pc-tag', help='Tag for separators, usually pc or c', default="pc")
|
||||
parser.add_argument('--parallel', help='Run in multiple processes, should speed things up')
|
||||
|
|
Loading…
Reference in New Issue
Block a user