![]() ![]() ![]() Meanwhile, we know from the November 2022 CSRD draft that companies could see as many as 85 disclosure requirements encompassing 1,100+ mandatory and material data points. The reports will need to follow European Sustainability Reporting Standards (ESRS), which are drafted and expected to be adopted by the EU formally in June 2023 under the guidance of the European Financial Reporting Advisory Group (EFRAG). (See where EFRAG fits into the ESG reporting landscape in the illustration below.) EU member states will then have until June 2024 to write the jurisdictional law within their country. This can be customized as you need, where the different sorting elements are simply stacked into this tuple in the order of importance for the sort.What kind of ESG data will the CSRD require companies to report? This works because a tuple is a legal key to use for sorting. Return (r, s1) # order first by 'fw'/'bw', then by nameįoolist.sort(key=sortfoo) # sorts foolist inplace R = 1 if s2 = 'fw' else 2 # forces 'fw' to come before 'bw' This does not require the functools module as in other examples: # task: sort the list of strings, such that items listed as '_fw' come before '_bw'įoolist = Here, Python can use a key as a str or tuple. So the solution, as I found, was to make a key which gives the right order. ![]() Afterwards, it determines which key is greater or lesser and puts them in the correct order. It builds a key list in a single pass through the list elements. One simple way to see it is that the sorted() (or list.sort()) function in Python operates on a single key at a time. Sorted(mylist, key=cmp_to_key(lambda item1, item2: fitness(item1) - fitness(item2))) ![]() Or: sorted(mylist, cmp=lambda item1, item2: fitness(item1) - fitness(item2))Ĭalling sorted() in Python 3 from functools import cmp_to_key If you want to reverse the sort order, simply reverse the subtraction: return fitness(item2) - fitness(item1) Calling sorted() in Python 2 sorted(mylist, cmp=compare) Using the minus operation is a nifty trick because it yields to positive values when the weight of left item1 is bigger than the weight of the right item2. In the particular case of the OP's question, the following custom compare function can be used: def compare(item1, item2):
0 Comments
Leave a Reply. |