I have a large list of tuples that follow the structure below:
('global_access', '2395', 'SQA', 'e69e1c69', '0', '/home/daoxley/git_stuff/sqa/sqa.yaml', '/home/daoxley/git_stuff/sqa/', '1.57.0')
('global_access', '2320', 'SQA', '7d1290cc', '0', '/home/daoxley/git_stuff/sqa/sqa.yaml', '/home/daoxley/git_stuff/sqa/', '1.57.0-7-g7d1290c')
('global_access', '2281', 'SQA', 'ead134e7', '0', '/home/daoxley/git_stuff/sqa/sqa.yaml', '/home/daoxley/git_stuff/sqa/', '1.57.0-9-gead134e')
('global_access', '2230', 'SQA', '8e3404b3', '0', '/home/daoxley/git_stuff/sqa/sqa.yaml', '/home/daoxley/git_stuff/sqa/', '1.57.0-12-g8e3404b')
('global_access', '2158', 'SQA', 'b19ba1fa', '0', '/home/daoxley/git_stuff/sqa/sqa.yaml', '/home/daoxley/git_stuff/sqa/', '1.57.0-15-gb19ba1f')
('global_access', '2345', 'SQA', '03fbe13d', '0', '/home/daoxley/git_stuff/sqa/sqa.yaml', '/home/daoxley/git_stuff/sqa/', '1.58.0')
I am trying to order this data based on the elements inside with some in ascending order and others descending. The order I want is 3rd (asc), 6th (asc), 7th (asc), 8th (desc) and 4th (desc).
I have done most of this already but I do not know how to order the 8th element in descending order so that the data will instead look like this:
('global_access', '2345', 'SQA', '03fbe13d', '0', '/home/daoxley/git_stuff/sqa/sqa.yaml', '/home/daoxley/git_stuff/sqa/', '1.58.0')
('global_access', '2158', 'SQA', 'b19ba1fa', '0', '/home/daoxley/git_stuff/sqa/sqa.yaml', '/home/daoxley/git_stuff/sqa/', '1.57.0-15-gb19ba1f')
('global_access', '2230', 'SQA', '8e3404b3', '0', '/home/daoxley/git_stuff/sqa/sqa.yaml', '/home/daoxley/git_stuff/sqa/', '1.57.0-12-g8e3404b')
('global_access', '2281', 'SQA', 'ead134e7', '0', '/home/daoxley/git_stuff/sqa/sqa.yaml', '/home/daoxley/git_stuff/sqa/', '1.57.0-9-gead134e')
('global_access', '2320', 'SQA', '7d1290cc', '0', '/home/daoxley/git_stuff/sqa/sqa.yaml', '/home/daoxley/git_stuff/sqa/', '1.57.0-7-g7d1290c')
('global_access', '2395', 'SQA', 'e69e1c69', '0', '/home/daoxley/git_stuff/sqa/sqa.yaml', '/home/daoxley/git_stuff/sqa/', '1.57.0')
Currently my code to sort looks like this:
rule_list_to_check.sort(key=lambda x: (x[2].lower(), x[5], x[6], LooseVersion(x[7])), -int(x[4]))
I have tried using reverse as below but this gives me the following error:
rule_list_to_check.sort(key=lambda x: (x[2].lower(), x[5], x[6], LooseVersion(x[7]), -int(x[4]),reverse=(False, False, False, True, False ))
And also trying to add - to LooseVersion(x[7]) gives an error also