SPDX-FileCopyrightText: 2022 fosslinux SPDX-License-Identifier: PSF-2.0 sorted() was only added in Python 2.5. But we are building Python 2.5. We cannot use .sort(), as it doesn't support the key= parameter. Instead we just use a basic custom selection sort to sort it ourselves using a custom key. --- Tools/compiler/astgen.py.bak 2022-07-11 09:24:59.600238862 +1000 +++ Tools/compiler/astgen.py 2022-07-11 09:32:25.814974174 +1000 @@ -215,7 +215,15 @@ # some extra code for a Node's __init__ method name = mo.group(1) cur = classes[name] - return sorted(classes.values(), key=lambda n: n.name) + ret = classes.values() + # basic custom selection sort + for i in range(len(ret)): + min_i = i + for j in range(i + 1, len(ret)): + if ret[min_i].name > ret[j].name: + min_i = j + ret[i], ret[min_i] = ret[min_i], ret[i] + return ret def main(): prologue, epilogue = load_boilerplate(sys.argv[-1])